github.com/chenbh/concourse/v6@v6.4.2/atc/resource/resource_test.go (about)

     1  package resource_test
     2  
     3  import (
     4  	. "github.com/onsi/ginkgo"
     5  	. "github.com/onsi/gomega"
     6  
     7  	"github.com/chenbh/concourse/v6/atc"
     8  	. "github.com/chenbh/concourse/v6/atc/resource"
     9  )
    10  
    11  var _ = Describe("Resource", func() {
    12  	Describe("ResourcesDir", func() {
    13  		It("returns a file path with a prefix", func() {
    14  			Expect(ResourcesDir("some-prefix")).To(ContainSubstring("some-prefix"))
    15  		})
    16  	})
    17  
    18  	Describe("Signature", func() {
    19  		var (
    20  			resource Resource
    21  			source   atc.Source
    22  			params   atc.Params
    23  			version  atc.Version
    24  		)
    25  
    26  		BeforeEach(func() {
    27  			source = atc.Source{"some-source-key": "some-source-value"}
    28  			params = atc.Params{"some-params-key": "some-params-value"}
    29  			version = atc.Version{"some-version-key": "some-version-value"}
    30  
    31  			resource = NewResourceFactory().NewResource(source, params, version)
    32  		})
    33  
    34  		It("marshals the source, params and version", func() {
    35  			actualSignature, err := resource.Signature()
    36  			Expect(err).ToNot(HaveOccurred())
    37  			Expect(actualSignature).To(MatchJSON(`{
    38  			  "source": {
    39  				"some-source-key": "some-source-value"
    40  			  },
    41  			  "params": {
    42  				"some-params-key": "some-params-value"
    43  			  },
    44  			  "version": {
    45  				"some-version-key": "some-version-value"
    46  			  }
    47  			}`))
    48  		})
    49  	})
    50  })