github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/yaml/utils_test.go (about) 1 package yaml 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 const ( 10 noSep = `this: is 11 some: yaml` 12 endSep = `iLoveYaml: meh 13 betterThanXml: true 14 ---` 15 startSep = `--- 16 someMap: 17 stuff: yes 18 things: also yes 19 ` 20 ) 21 22 func TestConcatYamlNoSeparators(t *testing.T) { 23 expected := `--- 24 someMap: 25 stuff: yes 26 things: also yes 27 --- 28 this: is 29 some: yaml` 30 assert.Equal(t, expected, ConcatYAML(startSep, noSep)) 31 } 32 33 func TestConcatYamlBothSeparators(t *testing.T) { 34 expected := `iLoveYaml: meh 35 betterThanXml: true 36 --- 37 someMap: 38 stuff: yes 39 things: also yes` 40 assert.Equal(t, expected, ConcatYAML(endSep, startSep)) 41 } 42 43 func TestConcatYamlEndSep(t *testing.T) { 44 expected := `iLoveYaml: meh 45 betterThanXml: true 46 --- 47 this: is 48 some: yaml` 49 assert.Equal(t, expected, ConcatYAML(endSep, noSep)) 50 } 51 52 func TestConcatYamlStartSep(t *testing.T) { 53 expected := `--- 54 someMap: 55 stuff: yes 56 things: also yes 57 --- 58 someMap: 59 stuff: yes 60 things: also yes` 61 assert.Equal(t, expected, ConcatYAML(startSep, startSep)) 62 } 63 64 func TestConcatManyYamls(t *testing.T) { 65 expected := `--- 66 someMap: 67 stuff: yes 68 things: also yes 69 --- 70 this: is 71 some: yaml 72 --- 73 iLoveYaml: meh 74 betterThanXml: true 75 ---` 76 77 assert.Equal(t, expected, ConcatYAML(startSep, noSep, endSep)) 78 } 79 80 func TestNoopConcatYaml(t *testing.T) { 81 assert.Equal(t, "", ConcatYAML()) 82 83 assert.Equal(t, noSep, ConcatYAML(noSep)) 84 }