Skip to content

Commit

Permalink
add test for some comment stripping corner cases
Browse files Browse the repository at this point in the history
Elliot-Roberts authored and budimanjojo committed Sep 9, 2024
1 parent b13e82d commit b029686
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/substitute/envsubst_test.go
Original file line number Diff line number Diff line change
@@ -83,3 +83,26 @@ default: default value
}
}
}

func TestComplexCommentStrip(t *testing.T) {
file := `a1: '123!@# not a comment'
a2: |
# not a comment
b1: '"' # comment
b2: "'" # comment
b3: "\"" # comment
`

expected := `a1: '123!@# not a comment'
a2: |
# not a comment
b1: '"'
b2: "'"
b3: "\""
`

result, _ := SubstituteEnvFromByte([]byte(file))
if expected != string(result) {
t.Errorf("got %s, want %s", string(result), expected)
}
}

0 comments on commit b029686

Please sign in to comment.