Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <18012015693@163.com>
  • Loading branch information
He1pa committed Jan 6, 2025
1 parent 2cd4142 commit 40cbfc0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/tools/gen/gentoml_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gen

import (
"fmt"
"testing"

"github.com/goccy/go-yaml"
Expand Down Expand Up @@ -100,12 +101,24 @@ c_key = "value3"
`,
expectErr: nil,
},

{
name: "Table Test",
data: &yaml.MapSlice{
{Key: "a_key", Value: map[string]string{
"a_a_key": "value2",
}},
{Key: "b_key", Value: "value1"},
},
expectedTOML: "",
expectErr: fmt.Errorf("unsupported to define 'b_key' after a table, ref: https://toml.io/en/v1.0.0#table"),
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tomlData, err := toml.Marshal(tt.data)
if err != tt.expectErr {
if err.Error() != tt.expectErr.Error() {
t.Fatalf("expected error: %v, got: %v", tt.expectErr, err)
}

Expand Down

0 comments on commit 40cbfc0

Please sign in to comment.