-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(init): add basic
structure.json
on init
When we create a new dataset, use the given format to determine what `formatConfig` options we want to expose to the user. Create the structure.json based on these options How do we handle `Separator`? It's a rune and marshals to an integer. Should probably be converted to a string?
- Loading branch information
Showing
6 changed files
with
102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package fsi | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestCreateBasicStructure(t *testing.T) { | ||
good := []struct { | ||
format string | ||
expectBytes []byte | ||
}{ | ||
{"csv", []byte(`{"format":"csv","formatConfig":{"headerRow":false,"lazyQuotes":false,"variadicFields":false}}`)}, | ||
{"json", []byte(`{"format":"json","formatConfig":{"pretty":false}}`)}, | ||
{"xlsx", []byte(`{"format":"xlsx","formatConfig":{"sheetName":"sheet1"}}`)}, | ||
} | ||
for _, c := range good { | ||
t.Run(fmt.Sprintf("good: %s", c.format), func(t *testing.T) { | ||
gotBytes, err := createBasicStructure(c.format) | ||
if err != nil { | ||
t.Errorf("expected no error. got: %s", err) | ||
} | ||
if !bytes.Equal(gotBytes, c.expectBytes) { | ||
t.Errorf("expected '%s', got '%s'", c.expectBytes, gotBytes) | ||
} | ||
}) | ||
} | ||
bad := []struct { | ||
format string | ||
err string | ||
}{ | ||
{"bad_format", "unknown body format 'bad_format'"}, | ||
} | ||
for _, c := range bad { | ||
t.Run(fmt.Sprintf("bad: %s", c.format), func(t *testing.T) { | ||
_, err := createBasicStructure(c.format) | ||
t.Log(err) | ||
if err == nil { | ||
t.Errorf("expected error. got: %s", err) | ||
} | ||
if err.Error() != c.err { | ||
t.Errorf("expected error '%s'. got: '%s'", c.err, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters