github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/test/integration/task/hash_test.go (about) 1 package tasktest 2 3 import ( 4 "github.com/Benchkram/bob/bobtask" 5 6 . "github.com/onsi/ginkgo" 7 . "github.com/onsi/gomega" 8 ) 9 10 var _ = Describe("Test task-related functionality", func() { 11 Context("in a fresh environment", func() { 12 const ( 13 shouldInfluenceText = "dummy text which should influence the exported structure" 14 ) 15 16 It("should produce the same hash for two tasks with the same exported structure", func() { 17 t1 := bobtask.Make() 18 t1h, err := t1.HashIn() 19 Expect(err).NotTo(HaveOccurred()) 20 21 t2 := bobtask.Make() 22 t2h, err := t2.HashIn() 23 Expect(err).NotTo(HaveOccurred()) 24 25 Expect(t1h).To(Equal(t2h)) 26 }) 27 28 It("should produce different hashes for two tasks with a different exported structure", func() { 29 t1 := bobtask.Make() 30 t1h, err := t1.HashIn() 31 Expect(err).NotTo(HaveOccurred()) 32 33 t2 := bobtask.Make() 34 t2.InputDirty = shouldInfluenceText 35 t2h, err := t2.HashIn() 36 Expect(err).NotTo(HaveOccurred()) 37 38 Expect(t1h).NotTo(Equal(t2h)) 39 }) 40 41 It("should produce the same hash for two taskst wih same environment", func() { 42 t1 := bobtask.Make(bobtask.WithEnvironment([]string{ 43 "PATH=/usr/bin", 44 })) 45 t1h, err := t1.HashIn() 46 Expect(err).NotTo(HaveOccurred()) 47 48 t2 := bobtask.Make(bobtask.WithEnvironment([]string{ 49 "PATH=/usr/bin", 50 })) 51 t2h, err := t2.HashIn() 52 Expect(err).NotTo(HaveOccurred()) 53 Expect(t1h).To(Equal(t2h)) 54 55 }) 56 57 It("should produce different hashes for two tasks with a different environments", func() { 58 t1 := bobtask.Make(bobtask.WithEnvironment([]string{ 59 "PATH=/usr/bin", 60 })) 61 t1h, err := t1.HashIn() 62 Expect(err).NotTo(HaveOccurred()) 63 64 t2 := bobtask.Make(bobtask.WithEnvironment([]string{ 65 "PATH=/usr/etc", 66 })) 67 t2h, err := t2.HashIn() 68 Expect(err).NotTo(HaveOccurred()) 69 70 Expect(t1h).NotTo(Equal(t2h)) 71 }) 72 73 }) 74 })