diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-24 10:37:54 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-24 10:37:54 -0800 |
commit | 04344fd03a609af37ec95a6c8279a45c17d5de70 (patch) | |
tree | 0129828f4a6eb5c1cfb2a02124fc4a14a22f4006 /cmd/ponzu/cli_test.go | |
parent | 6f5893828077eb0034dca01344f3742eb5cd5fa6 (diff) |
adding initial support to generate content type from more descriptive cli args
Diffstat (limited to 'cmd/ponzu/cli_test.go')
-rw-r--r-- | cmd/ponzu/cli_test.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/cmd/ponzu/cli_test.go b/cmd/ponzu/cli_test.go new file mode 100644 index 0000000..76feac3 --- /dev/null +++ b/cmd/ponzu/cli_test.go @@ -0,0 +1,65 @@ +package main + +import "testing" + +func TestParseType(t *testing.T) { + // blog title:string Author:string PostCategory:string content:string some_thing:int + args := []string{ + "blog", "title:string", "Author:string", + "PostCategory:string", "content:string", + "some_thing:int", "Some_otherThing:float64", + } + + gt, err := parseType(args) + if err != nil { + t.Errorf("Failed: %s", err.Error()) + } + + if gt.Name != "Blog" { + t.Errorf("Expected %s, got: %s", "Blog", gt.Name) + } +} + +func TestFieldJSONName(t *testing.T) { + cases := map[string]string{ + "_T": "t", + "T": "t", + "_tT_": "t_t_", + "TestCapsNoSym": "test_caps_no_sym", + "test_Some_caps_Sym": "test_some_caps_sym", + "testnocaps": "testnocaps", + "_Test_Caps_Sym_odd": "test_caps_sym_odd", + "test-hyphen": "test-hyphen", + "Test-hyphen-Caps": "test-hyphen-caps", + "Test-Hyphen_Sym-Caps": "test-hyphen_sym-caps", + } + + for input, expected := range cases { + output := fieldJSONName(input) + if output != expected { + t.Errorf("Expected: %s, got: %s", expected, output) + } + } +} + +func TestFieldName(t *testing.T) { + cases := map[string]string{ + "_T": "T", + "T": "T", + "_tT_": "TT", + "TestCapsNoSym": "TestCapsNoSym", + "test_Some_caps_Sym": "TestSomeCapsSym", + "testnocaps": "Testnocaps", + "_Test_Caps_Sym_odd": "TestCapsSymOdd", + "test-hyphen": "TestHyphen", + "Test-hyphen-Caps": "TestHyphenCaps", + "Test-Hyphen_Sym-Caps": "TestHyphenSymCaps", + } + + for input, expected := range cases { + output := fieldName(input) + if output != expected { + t.Errorf("Expected: %s, got: %s", expected, output) + } + } +} |