X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=binapigen%2Fvppapi%2Fvppapi_test.go;fp=binapigen%2Fvppapi%2Fparser_test.go;h=027cc1f583bce85205a957fbf2b956bb4bdb4e64;hb=d1f24d37bd447b64e402298bb8eb2479681facf9;hp=2dc82e4b2be885e063fb59858463e09b31a743ea;hpb=1548c7e12531e3d055567d761c580a1c7ff0ac40;p=govpp.git diff --git a/binapigen/vppapi/parser_test.go b/binapigen/vppapi/vppapi_test.go similarity index 85% rename from binapigen/vppapi/parser_test.go rename to binapigen/vppapi/vppapi_test.go index 2dc82e4..027cc1f 100644 --- a/binapigen/vppapi/parser_test.go +++ b/binapigen/vppapi/vppapi_test.go @@ -46,7 +46,7 @@ func TestReadJson(t *testing.T) { inputData, err := ioutil.ReadFile("testdata/af_packet.api.json") Expect(err).ShouldNot(HaveOccurred()) - result, err := parseJSON(inputData) + result, err := ParseRaw(inputData) Expect(err).ShouldNot(HaveOccurred()) Expect(result).ToNot(BeNil()) Expect(result.EnumTypes).To(HaveLen(0)) @@ -60,7 +60,7 @@ func TestReadJsonError(t *testing.T) { inputData, err := ioutil.ReadFile("testdata/input-read-json-error.json") Expect(err).ShouldNot(HaveOccurred()) - result, err := parseJSON(inputData) + result, err := ParseRaw(inputData) Expect(err).Should(HaveOccurred()) Expect(result).To(BeNil()) } @@ -80,17 +80,21 @@ func TestParseFile(t *testing.T) { if module.Name != "vpe" { t.Errorf("expected Name=%s, got %v", "vpe", module.Name) } + if module.Path != "testdata/vpe.api.json" { + t.Errorf("expected Path=%s, got %v", "testdata/vpe.api.json", module.Path) + } if module.CRC != "0xbd2c94f4" { t.Errorf("expected CRC=%s, got %v", "0xbd2c94f4", module.CRC) } - if module.Version() != "1.6.1" { - t.Errorf("expected Version=%s, got %v", "1.6.1", module.Version()) + + if version := module.Options["version"]; version != "1.6.1" { + t.Errorf("expected option[version]=%s, got %v", "1.6.1", version) } if len(module.Imports) == 0 { t.Errorf("expected imports, got none") } - if len(module.Options) == 0 { - t.Errorf("expected options, got none") + if len(module.EnumTypes) == 0 { + t.Errorf("expected enums, got none") } if len(module.AliasTypes) == 0 { t.Errorf("expected aliases, got none") @@ -98,12 +102,12 @@ func TestParseFile(t *testing.T) { if len(module.StructTypes) == 0 { t.Errorf("expected types, got none") } - if len(module.Service.RPCs) == 0 { - t.Errorf("expected service method, got none") - } if len(module.Messages) == 0 { t.Errorf("expected messages, got none") } + if len(module.Service.RPCs) == 0 { + t.Errorf("expected service RPCs, got none") + } } func TestParseFileUnsupported(t *testing.T) {