Skip to content

Implement review comment changes #5

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

Merged
merged 1 commit into from
Nov 27, 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
15 changes: 10 additions & 5 deletions example/weather/services/front/clients/tester/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (

type (
Client interface {
// Run smoke tests
// Runs ALL API Integration Tests from the Tester service, allowing for filtering on included or excluded tests
TestAll(ctx context.Context, included, excluded []string) (*genfront.TestResults, error)
// Runs API Integration Tests' Smoke Tests ONLY from the Tester service
TestSmoke(ctx context.Context) (*genfront.TestResults, error)
TestAll(ctx context.Context, payload *TestAllPayload) (*genfront.TestResults, error)
}

TestAllPayload struct {
Expand All @@ -31,6 +32,7 @@ type (
}
)

// Creates a new client for the Tester service.
func New(cc *grpc.ClientConn) Client {
c := genclient.NewClient(cc, grpc.WaitForReady(true))
return &client{
Expand All @@ -39,6 +41,7 @@ func New(cc *grpc.ClientConn) Client {
}
}

// TestSmoke runs the Smoke collection as defined in func_map.go of the tester service
func (c *client) TestSmoke(ctx context.Context) (*genfront.TestResults, error) {
res, err := c.testSmoke(ctx, nil)
if err != nil {
Expand All @@ -48,10 +51,12 @@ func (c *client) TestSmoke(ctx context.Context) (*genfront.TestResults, error) {
return testerTestResultsToFrontTestResults(res.(*gentester.TestResults)), nil
}

func (c *client) TestAll(ctx context.Context, payload *TestAllPayload) (*genfront.TestResults, error) {
// TestAll runs all tests in all collections. Obeys include and exclude filters.
// include and exclude are mutually exclusive and cannot be used together (400 error, bad request)
func (c *client) TestAll(ctx context.Context, included, excluded []string) (*genfront.TestResults, error) {
gtPayload := &gentester.TesterPayload{
Include: payload.Include,
Exclude: payload.Exclude,
Include: included,
Exclude: excluded,
}
res, err := c.testAll(ctx, gtPayload)
if err != nil {
Expand Down
34 changes: 17 additions & 17 deletions example/weather/services/front/clients/tester/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/weather/services/front/design/design.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = Service("front", func() {
})
})
Method("test_all", func() {
Description("Endpoint for running API Integration Tests for the Weather System")
Description("Endpoint for running ALL API Integration Tests for the Weather System, allowing for filtering on included or excluded tests")
Payload(func() {
Field(1, "include", ArrayOf(String), "Tests to run")
Field(2, "exclude", ArrayOf(String), "Tests to exclude")
Expand All @@ -37,7 +37,7 @@ var _ = Service("front", func() {
})
})
Method("test_smoke", func() {
Description("Endpoint for running API Integration Tests for the Weather System")
Description("Endpoint for running API Integration Tests' Smoke Tests ONLY for the Weather System")
Result(TestResults)
HTTP(func() {
POST("/tester/smoke")
Expand Down
42 changes: 31 additions & 11 deletions example/weather/services/front/design/tester_results.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,50 @@ import (

var TestResult = Type("TestResult", func() {
Description("Test result for a single test")
Field(1, "name", String, "Name of the test")
Field(1, "name", String, "Name of the test", func() {
Example("TestValidIP")
})
Field(2, "passed", Boolean, "Status of the test", func() {
Example(true)
})
Field(3, "error", String, "Error message if the test failed")
Field(4, "duration", Int64, "Duration of the test in ns")
Field(3, "error", String, "Error message if the test failed", func() {
Example("error getting location for valid ip: %v")
})
Field(4, "duration", Int64, "Duration of the test in ms", func() {
Example(1234)
})
Required("name", "passed", "duration")
})

var TestCollection = Type("TestCollection", func() {
Description("Collection of test results for grouping by service")
Field(1, "name", String, "Name of the test collection")
Field(1, "name", String, "Name of the test collection", func() {
Example("Locator Tests")
})
Field(2, "results", ArrayOf(TestResult), "Test results")
Field(3, "duration", Int64, "Duration of the tests in ns")
Field(4, "pass_count", Int, "Number of tests that passed")
Field(5, "fail_count", Int, "Number of tests that failed")
Required("name", "results", "duration", "pass_count", "fail_count")
Field(3, "duration", Int64, "Duration of the tests in ms", func() {
Example(1234)
})
Field(4, "pass_count", Int, "Number of tests that passed", func() {
Example(12)
})
Field(5, "fail_count", Int, "Number of tests that failed", func() {
Example(1)
})
Required("name", "duration", "pass_count", "fail_count")
})

var TestResults = Type("TestResults", func() {
Description("Test results for the iam system integration tests")
Field(1, "collections", ArrayOf(TestCollection), "Test collections")
Field(2, "duration", Int64, "Duration of the tests in ns")
Field(3, "pass_count", Int, "Number of tests that passed")
Field(4, "fail_count", Int, "Number of tests that failed")
Field(2, "duration", Int64, "Duration of the tests in ms", func() {
Example(1234)
})
Field(3, "pass_count", Int, "Number of tests that passed", func() {
Example(12)
})
Field(4, "fail_count", Int, "Number of tests that failed", func() {
Example(1)
})
Required("collections", "duration", "pass_count", "fail_count")
})
5 changes: 3 additions & 2 deletions example/weather/services/front/front.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ func (s *Service) Forecast(ctx context.Context, ip string) (*genfront.Forecast2,
return &genfront.Forecast2{Location: &loc, Periods: ps}, nil
}

// Runs ALL API Integration Tests from the Tester service, allowing for filtering on included or excluded tests
func (s *Service) TestAll(ctx context.Context, payload *genfront.TestAllPayload) (*genfront.TestResults, error) {
tcPayload := &tester.TestAllPayload{Include: payload.Include, Exclude: payload.Exclude}
return s.tc.TestAll(ctx, tcPayload)
return s.tc.TestAll(ctx, payload.Include, payload.Exclude)
}

// Runs API Integration Tests' Smoke Tests ONLY from the Tester service
func (s *Service) TestSmoke(ctx context.Context) (*genfront.TestResults, error) {
return s.tc.TestSmoke(ctx)
}
12 changes: 7 additions & 5 deletions example/weather/services/front/gen/front/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions example/weather/services/front/gen/http/cli/weather/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions example/weather/services/front/gen/http/front/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading