github.com/mutagen-io/mutagen@v0.18.0-rc1/pkg/environment/block_test.go (about) 1 package environment 2 3 import ( 4 "testing" 5 ) 6 7 // TestParseBlock tests ParseBlock. 8 func TestParseBlock(t *testing.T) { 9 // Set test parameters. 10 input := "KEY=VALUE\nKEY=duplicate\r\nOTHER=2\nIGNORED\n\n" 11 expected := []string{ 12 "KEY=VALUE", 13 "KEY=duplicate", 14 "OTHER=2", 15 "IGNORED", 16 } 17 18 // Perform parsing. 19 output := ParseBlock(input) 20 21 // Validate results. 22 if len(output) != len(expected) { 23 t.Fatal("output length does not match expected:", len(output), "!=", len(expected)) 24 } 25 for v, value := range output { 26 if value != expected[v] { 27 t.Error("output value at index", v, "does not match expected:", value, "!=", expected[v]) 28 } 29 } 30 }