github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/fly/commands/internal/setpipelinehelpers/atc_config_test.go (about)

     1  package setpipelinehelpers_test
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/pf-qiu/concourse/v6/atc"
     8  	. "github.com/pf-qiu/concourse/v6/fly/commands/internal/setpipelinehelpers"
     9  
    10  	. "github.com/onsi/ginkgo"
    11  	. "github.com/onsi/gomega"
    12  )
    13  
    14  var _ = Describe("ATC Config", func() {
    15  	Describe("Apply configuration interaction", func() {
    16  		var atcConfig ATCConfig
    17  		BeforeEach(func() {
    18  			atcConfig = ATCConfig{
    19  				SkipInteraction: true,
    20  			}
    21  		})
    22  
    23  		Context("when the skip interaction flag has been set to true", func() {
    24  			It("returns true", func() {
    25  				Expect(atcConfig.ApplyConfigInteraction()).To(BeTrue())
    26  			})
    27  		})
    28  	})
    29  
    30  })
    31  
    32  var _ = Describe("UnpausePipelineCommand", func() {
    33  	It("uses the right target and pipeline ref", func() {
    34  		atcConfig := ATCConfig{
    35  			TargetName: "my-target",
    36  			PipelineRef: atc.PipelineRef{
    37  				Name:         "my-pipeline",
    38  				InstanceVars: atc.InstanceVars{"branch": "master"},
    39  			},
    40  		}
    41  		expected := fmt.Sprintf("%s -t my-target unpause-pipeline -p my-pipeline/branch:master", os.Args[0])
    42  		Expect(atcConfig.UnpausePipelineCommand()).To(Equal(expected))
    43  	})
    44  
    45  	Context("when the instance vars require quoting", func() {
    46  		It("quotes the pipeline flag", func() {
    47  			atcConfig := ATCConfig{
    48  				TargetName: "my-target",
    49  				PipelineRef: atc.PipelineRef{
    50  					Name:         "my-pipeline",
    51  					InstanceVars: atc.InstanceVars{"a.b": "master"},
    52  				},
    53  			}
    54  			expected := fmt.Sprintf(`%s -t my-target unpause-pipeline -p "my-pipeline/\"a.b\":master"`, os.Args[0])
    55  			Expect(atcConfig.UnpausePipelineCommand()).To(Equal(expected))
    56  		})
    57  	})
    58  })