This repository has no description
1package spindle
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7
8 "tangled.org/core/workflow"
9)
10
11func TestFingerprintWorkflowDefinition(t *testing.T) {
12 a := workflow.RawWorkflow{Name: "a.yml", Contents: []byte("engine: dummy\n")}
13 b := workflow.RawWorkflow{Name: "b.yml", Contents: []byte("engine: nixery\n")}
14
15 // iteration order must not affect the fingerprint
16 assert.Equal(t,
17 fingerprintWorkflowDefinition(workflow.RawPipeline{a, b}),
18 fingerprintWorkflowDefinition(workflow.RawPipeline{b, a}),
19 )
20
21 // content and name changes must both change the fingerprint
22 base := fingerprintWorkflowDefinition(workflow.RawPipeline{a, b})
23 assert.NotEqual(t, base, fingerprintWorkflowDefinition(workflow.RawPipeline{
24 {Name: "a.yml", Contents: []byte("engine: nixery\n")}, b,
25 }))
26 assert.NotEqual(t, base, fingerprintWorkflowDefinition(workflow.RawPipeline{
27 {Name: "c.yml", Contents: a.Contents}, b,
28 }))
29
30 assert.NotEqual(t,
31 fingerprintWorkflowDefinition(nil),
32 fingerprintWorkflowDefinition(workflow.RawPipeline{a}),
33 )
34}