Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataapiv2 - Add github actions to dataapiv2 #3428

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/unit-test-data-api-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Verify Data API V2 API Definitions Can be Mapped
on:
pull_request:
types: ['opened', 'synchronize']
paths:
- '.github/workflows/**'
- 'tools/data-api/**'

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
submodules: recursive

- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21.3'

- name: run unit tests
run: |
cd ./tools/data-api
make test
3 changes: 3 additions & 0 deletions tools/data-api/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ fmt:
run: build
./data-api serve

test: build
go test -v ./...

.PHONY: build fmt run
2 changes: 1 addition & 1 deletion tools/data-api/internal/endpoints/v1/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func mapDateFormat(input *repositories.DateFormat) (*models.DateFormat, error) {
if v, ok := mappings[*input]; ok {
return &v, nil
}
return nil, fmt.Errorf("unmapped date format %q", input)
return nil, fmt.Errorf("unmapped date format %+v", input)
}

return nil, nil
Expand Down
27 changes: 27 additions & 0 deletions tools/data-api/internal/repositories/services_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package repositories

import (
"testing"
)

func TestServices_ResourceManager(t *testing.T) {
repo, err := NewServicesRepository("../../../../api-definitions/", ResourceManagerServiceType, nil)
if err != nil {
t.Fatalf(err.Error())
}

if _, err := repo.GetAll(ResourceManagerServiceType); err != nil {
t.Fatalf(err.Error())
}
}

func TestServices_MicrosoftGraph(t *testing.T) {
repo, err := NewServicesRepository("../../../../api-definitions/", MicrosoftGraphV1StableServiceType, nil)
if err != nil {
t.Fatalf(err.Error())
}

if _, err := repo.GetAll(MicrosoftGraphV1StableServiceType); err != nil {
t.Fatalf(err.Error())
}
}
2 changes: 1 addition & 1 deletion tools/data-api/internal/repositories/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func validateModels(input map[string]ModelDetails, constants map[string]Constant

parentModel, ok := input[*modelDetail.ParentTypeName]
if !ok {
return fmt.Errorf("model %q: discriminated parent type model %q not found", *modelDetail.ParentTypeName)
return fmt.Errorf("model %q: discriminated parent type model %q not found", modelName, *modelDetail.ParentTypeName)
}

typeHintIn := ""
Expand Down
Loading