Skip to content

Commit

Permalink
Fix Go API view package path render issue and add Go test to APIview …
Browse files Browse the repository at this point in the history
…CI (#5750)

* fix issue of go package path render and add go test to api view ci

* fix ci

* Update apiview.yml
  • Loading branch information
tadelesh authored Mar 21, 2023
1 parent aa87ee6 commit bbc17f1
Show file tree
Hide file tree
Showing 14 changed files with 280 additions and 309 deletions.
12 changes: 12 additions & 0 deletions src/dotnet/APIView/apiview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trigger:
- .azure-pipelines/apiview.yml
- src/dotnet/APIView
- src/java/apiview-java-processor
- src/go
- src/swift
- tools/apiview/parsers/js-api-parser

Expand All @@ -25,6 +26,7 @@ pr:
- .azure-pipelines/apiview.yml
- src/dotnet/APIView
- src/java/apiview-java-processor
- src/go
- src/swift
- tools/apiview/parsers/js-api-parser

Expand Down Expand Up @@ -171,6 +173,16 @@ stages:
dotnet --version
displayName: 'List .Net run times'
- task: GoTool@0
inputs:
version: '$(GoVersion)'
displayName: "Use Go $(GoVersion)"

- script: |
go test ./... -v
workingDirectory: $(GoParserPackagePath)
displayName: 'Test Go parser'
- script: >-
dotnet test src/dotnet/APIView/APIViewUnitTests/APIViewUnitTests.csproj
--logger trx --collect:"XPlat Code Coverage"
Expand Down
28 changes: 14 additions & 14 deletions src/go/cmd/api_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func TestMain(m *testing.M) {
}

func TestFuncDecl(t *testing.T) {
err := CreateAPIView(filepath.Clean("testdata/test_funcDecl"), "output")
err := CreateAPIView(filepath.Clean("testdata/test_func_decl"), "output")
if err != nil {
t.Fatal(err)
}
file, err := os.ReadFile("./output/testfuncdecl.json")
file, err := os.ReadFile("./output/test_func_decl.json")
if err != nil {
t.Fatal(err)
}
Expand All @@ -31,10 +31,10 @@ func TestFuncDecl(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(p.Tokens) != 41 {
if len(p.Tokens) != 42 {
t.Fatal("unexpected token length, signals a change in the output")
}
if p.Name != "testfuncdecl" {
if p.Name != "test_func_decl" {
t.Fatal("unexpected package name")
}
if len(p.Navigation) != 1 {
Expand All @@ -50,7 +50,7 @@ func TestInterface(t *testing.T) {
if err != nil {
t.Fatal(err)
}
file, err := os.ReadFile("./output/testinterface.json")
file, err := os.ReadFile("./output/test_interface.json")
if err != nil {
t.Fatal(err)
}
Expand All @@ -59,10 +59,10 @@ func TestInterface(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(p.Tokens) != 55 {
if len(p.Tokens) != 46 {
t.Fatal("unexpected token length, signals a change in the output")
}
if p.Name != "testinterface" {
if p.Name != "test_interface" {
t.Fatal("unexpected package name")
}
if len(p.Navigation) != 1 {
Expand All @@ -78,7 +78,7 @@ func TestStruct(t *testing.T) {
if err != nil {
t.Fatal(err)
}
file, err := os.ReadFile("./output/teststruct.json")
file, err := os.ReadFile("./output/test_struct.json")
if err != nil {
t.Fatal(err)
}
Expand All @@ -87,16 +87,16 @@ func TestStruct(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(p.Tokens) != 69 {
if len(p.Tokens) != 68 {
t.Fatal("unexpected token length, signals a change in the output")
}
if p.Name != "teststruct" {
if p.Name != "test_struct" {
t.Fatal("unexpected package name")
}
if len(p.Navigation) != 1 {
t.Fatal("nagivation slice length should only be one for one package")
}
if len(p.Navigation[0].ChildItems) != 2 {
if len(p.Navigation[0].ChildItems) != 1 {
t.Fatal("nagivation slice length should include link for ctor and struct")
}
}
Expand All @@ -106,7 +106,7 @@ func TestConst(t *testing.T) {
if err != nil {
t.Fatal(err)
}
file, err := os.ReadFile("./output/testconst.json")
file, err := os.ReadFile("./output/test_const.json")
if err != nil {
t.Fatal(err)
}
Expand All @@ -118,13 +118,13 @@ func TestConst(t *testing.T) {
if len(p.Tokens) != 76 {
t.Fatal("unexpected token length, signals a change in the output")
}
if p.Name != "testconst" {
if p.Name != "test_const" {
t.Fatal("unexpected package name")
}
if len(p.Navigation) != 1 {
t.Fatal("nagivation slice length should only be one for one package")
}
if len(p.Navigation[0].ChildItems) != 3 {
if len(p.Navigation[0].ChildItems) != 4 {
t.Fatal("unexpected child navigation items length")
}
}
Expand Down
Loading

0 comments on commit bbc17f1

Please sign in to comment.