From d12ef5ebf13732d13c199aa7e1d32cb7695be13b Mon Sep 17 00:00:00 2001 From: Gerrit Date: Tue, 24 Mar 2026 15:30:59 +0100 Subject: [PATCH] Test interceptor was moved to API repo. --- go.mod | 6 +-- go.sum | 12 ++--- testing/e2e/{test_client.go => test_cmd.go} | 8 +-- testing/e2e/test_interceptor.go | 60 --------------------- testing/e2e/test_interceptor_test.go | 55 ------------------- tests/e2e/admin/component_test.go | 7 +-- tests/e2e/admin/project_test.go | 3 +- tests/e2e/admin/switch_test.go | 7 +-- tests/e2e/admin/tenant_test.go | 5 +- tests/e2e/admin/token_test.go | 5 +- tests/e2e/api/audit_test.go | 5 +- tests/e2e/api/health_test.go | 3 +- tests/e2e/api/image_test.go | 5 +- tests/e2e/api/ip_test.go | 21 ++++---- tests/e2e/api/project_test.go | 19 +++---- tests/e2e/api/tenant_test.go | 5 +- tests/e2e/api/token_test.go | 5 +- 17 files changed, 62 insertions(+), 169 deletions(-) rename testing/e2e/{test_client.go => test_cmd.go} (92%) delete mode 100644 testing/e2e/test_interceptor.go delete mode 100644 testing/e2e/test_interceptor_test.go diff --git a/go.mod b/go.mod index b2ccb7f..2b5dd36 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/dustin/go-humanize v1.0.1 github.com/fatih/color v1.18.0 github.com/google/go-cmp v0.7.0 - github.com/metal-stack/api v0.0.55 + github.com/metal-stack/api v0.0.58 github.com/metal-stack/metal-lib v0.24.0 github.com/metal-stack/v v1.0.3 github.com/spf13/afero v1.15.0 @@ -68,8 +68,8 @@ require ( golang.org/x/net v0.50.0 // indirect golang.org/x/sys v0.41.0 // indirect golang.org/x/text v0.35.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20260311181403-84a4fc48630c // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20260316180232-0b37fe3546d5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260316180232-0b37fe3546d5 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/apimachinery v0.35.1 // indirect diff --git a/go.sum b/go.sum index 62e0050..d420c4c 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.20 h1:WcT52H91ZUAwy8+HUkdM3THM6gXqXuLJi9O3rjcQQaQ= github.com/mattn/go-runewidth v0.0.20/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= -github.com/metal-stack/api v0.0.55 h1:n5Y91x+B5/rh6j9rai6CAgVWenLgEzAQwFD2nYbVDXA= -github.com/metal-stack/api v0.0.55/go.mod h1:OU8KDSOw5JEfeEs9q8FY5TcaklBAiGx+Q9Em0BMZrlY= +github.com/metal-stack/api v0.0.58 h1:7UxnZrM41BS0f4S9RvqDg0/YTvs3FveawuyBoKz9WhA= +github.com/metal-stack/api v0.0.58/go.mod h1:hEgtKVD7UnUwUExdA7pbFvVRxNRxSGUnU+bZce46//c= github.com/metal-stack/metal-lib v0.24.0 h1:wvQQPWIXcA2tP+I6zAHUNdtVLLJfQnnV9yG2SoqUkz4= github.com/metal-stack/metal-lib v0.24.0/go.mod h1:oITaqj/BtB9vDKM66jCXkeA+4D0eTZElgIKal5vtiNY= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs= @@ -133,10 +133,10 @@ golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k= golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8= golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA= -google.golang.org/genproto/googleapis/api v0.0.0-20260311181403-84a4fc48630c h1:OyQPd6I3pN/9gDxz6L13kYGJgqkpdrAohJRBeXyxlgI= -google.golang.org/genproto/googleapis/api v0.0.0-20260311181403-84a4fc48630c/go.mod h1:X2gu9Qwng7Nn009s/r3RUxqkzQNqOrAy79bluY7ojIg= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c h1:xgCzyF2LFIO/0X2UAoVRiXKU5Xg6VjToG4i2/ecSswk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260311181403-84a4fc48630c/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/genproto/googleapis/api v0.0.0-20260316180232-0b37fe3546d5 h1:CogIeEXn4qWYzzQU0QqvYBM8yDF9cFYzDq9ojSpv0Js= +google.golang.org/genproto/googleapis/api v0.0.0-20260316180232-0b37fe3546d5/go.mod h1:EIQZ5bFCfRQDV4MhRle7+OgjNtZ6P1PiZBgAKuxXu/Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260316180232-0b37fe3546d5 h1:aJmi6DVGGIStN9Mobk/tZOOQUBbj0BPjZjjnOdoZKts= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260316180232-0b37fe3546d5/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= google.golang.org/grpc v1.79.1 h1:zGhSi45ODB9/p3VAawt9a+O/MULLl9dpizzNNpq7flY= google.golang.org/grpc v1.79.1/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= diff --git a/testing/e2e/test_client.go b/testing/e2e/test_cmd.go similarity index 92% rename from testing/e2e/test_client.go rename to testing/e2e/test_cmd.go index ab8cf1d..93504f4 100644 --- a/testing/e2e/test_client.go +++ b/testing/e2e/test_cmd.go @@ -20,17 +20,13 @@ import ( type TestConfig struct { FsMocks func(fs *afero.Afero) MockStdin *bytes.Buffer - ClientCalls []ClientCall + ClientCalls []client.ClientCall } func NewRootCmd(t *testing.T, c *TestConfig) NewRootCmdFunc { return func() (*cobra.Command, *bytes.Buffer) { interceptors := []connect.Interceptor{ - &testClientInterceptor{ - t: t, - calls: c.ClientCalls, - count: 0, - }, + client.NewTestInterceptor(t, c.ClientCalls), validate.NewInterceptor(), } diff --git a/testing/e2e/test_interceptor.go b/testing/e2e/test_interceptor.go deleted file mode 100644 index dc43709..0000000 --- a/testing/e2e/test_interceptor.go +++ /dev/null @@ -1,60 +0,0 @@ -package e2e - -import ( - "context" - "testing" - - "connectrpc.com/connect" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - "github.com/metal-stack/metal-lib/pkg/testcommon" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/runtime/protoimpl" - "google.golang.org/protobuf/testing/protocmp" -) - -type testClientInterceptor struct { - t *testing.T - calls []ClientCall - count int -} - -type ClientCall struct { - WantRequest proto.Message - WantResponse func() connect.AnyResponse - WantError *connect.Error -} - -func (t *testClientInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc { - return func(ctx context.Context, ar connect.AnyRequest) (connect.AnyResponse, error) { - defer func() { t.count++ }() - - if t.count >= len(t.calls) { - t.t.Errorf("received an unexpected client call of type %T: %v", ar.Any(), ar.Any()) - t.t.FailNow() - } - - call := t.calls[t.count] - - if diff := cmp.Diff(call.WantRequest, ar.Any(), protocmp.Transform(), testcommon.IgnoreUnexported(), cmpopts.IgnoreTypes(protoimpl.MessageState{})); diff != "" { - t.t.Errorf("request diff (+got -want):\n %s", diff) - t.t.FailNow() - } - - if call.WantError != nil { - return nil, call.WantError - } - - return call.WantResponse(), nil - } -} - -func (t *testClientInterceptor) WrapStreamingClient(connect.StreamingClientFunc) connect.StreamingClientFunc { - t.t.Errorf("streaming not supported") - return nil -} - -func (t *testClientInterceptor) WrapStreamingHandler(connect.StreamingHandlerFunc) connect.StreamingHandlerFunc { - t.t.Errorf("streaming not supported") - return nil -} diff --git a/testing/e2e/test_interceptor_test.go b/testing/e2e/test_interceptor_test.go deleted file mode 100644 index 3305c01..0000000 --- a/testing/e2e/test_interceptor_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package e2e - -import ( - "log/slog" - "testing" - - "connectrpc.com/connect" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" - client "github.com/metal-stack/api/go/client" - apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" - "github.com/metal-stack/metal-lib/pkg/testcommon" - "github.com/stretchr/testify/require" - "google.golang.org/protobuf/runtime/protoimpl" - "google.golang.org/protobuf/testing/protocmp" -) - -func TestInterceptor(t *testing.T) { - cl, err := client.New(&client.DialConfig{ - BaseURL: "http://this-is-just-for-testing", - Interceptors: []connect.Interceptor{ - &testClientInterceptor{ - t: t, - calls: []ClientCall{ - { - WantRequest: &apiv2.IPServiceGetRequest{ - Ip: "1.2.3.4", - }, - WantResponse: func() connect.AnyResponse { - return connect.NewResponse(&apiv2.IPServiceGetResponse{ - Ip: &apiv2.IP{Ip: "1.2.3.4"}, - }) - }, - }, - }, - }, - }, - UserAgent: "cli-test", - Log: slog.Default(), - }) - require.NoError(t, err) - - resp, err := cl.Apiv2().IP().Get(t.Context(), &apiv2.IPServiceGetRequest{ - Ip: "1.2.3.4", - }) - require.NoError(t, err) - - if diff := cmp.Diff(&apiv2.IPServiceGetResponse{ - Ip: &apiv2.IP{ - Ip: "1.2.3.4", - }, - }, resp, protocmp.Transform(), testcommon.IgnoreUnexported(), cmpopts.IgnoreTypes(protoimpl.MessageState{})); diff != "" { - t.Errorf("diff = %s", diff) - } -} diff --git a/tests/e2e/admin/component_test.go b/tests/e2e/admin/component_test.go index 26f68ae..cd9c43b 100644 --- a/tests/e2e/admin/component_test.go +++ b/tests/e2e/admin/component_test.go @@ -5,6 +5,7 @@ import ( "time" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" @@ -55,7 +56,7 @@ func Test_AdminComponentCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"admin", "component", "describe", component1().Uuid}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.ComponentServiceGetRequest{ Uuid: component1().Uuid, @@ -100,7 +101,7 @@ func Test_AdminComponentCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"admin", "component", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.ComponentServiceListRequest{ Query: &apiv2.ComponentQuery{}, @@ -150,7 +151,7 @@ func Test_AdminComponentCmd_Delete(t *testing.T) { Name: "delete", CmdArgs: []string{"admin", "component", "delete", component1().Uuid}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.ComponentServiceDeleteRequest{ Uuid: component1().Uuid, diff --git a/tests/e2e/admin/project_test.go b/tests/e2e/admin/project_test.go index 2739239..357e227 100644 --- a/tests/e2e/admin/project_test.go +++ b/tests/e2e/admin/project_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" @@ -16,7 +17,7 @@ func Test_AdminProjectCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"admin", "project", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.ProjectServiceListRequest{}, WantResponse: func() connect.AnyResponse { diff --git a/tests/e2e/admin/switch_test.go b/tests/e2e/admin/switch_test.go index 60a9581..1cd9985 100644 --- a/tests/e2e/admin/switch_test.go +++ b/tests/e2e/admin/switch_test.go @@ -5,6 +5,7 @@ import ( "time" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" @@ -65,7 +66,7 @@ func Test_AdminSwitchCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"admin", "switch", "describe", switch1().Id}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.SwitchServiceGetRequest{ Id: switch1().Id, @@ -93,7 +94,7 @@ func Test_AdminSwitchCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"admin", "switch", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.SwitchServiceListRequest{ Query: &apiv2.SwitchQuery{ @@ -145,7 +146,7 @@ func Test_AdminSwitchCmd_Delete(t *testing.T) { Name: "delete", CmdArgs: []string{"admin", "switch", "delete", switch1().Id}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.SwitchServiceDeleteRequest{ Id: switch1().Id, diff --git a/tests/e2e/admin/tenant_test.go b/tests/e2e/admin/tenant_test.go index 9c96572..3914611 100644 --- a/tests/e2e/admin/tenant_test.go +++ b/tests/e2e/admin/tenant_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" @@ -41,7 +42,7 @@ func Test_AdminTenantCmd_Create(t *testing.T) { Name: "create", CmdArgs: []string{"admin", "tenant", "create", "--name", adminTenant1().Name, "--description", adminTenant1().Description, "--email", adminTenant1().Email}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.TenantServiceCreateRequest{ Name: adminTenant1().Name, @@ -71,7 +72,7 @@ func Test_AdminTenantCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"admin", "tenant", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.TenantServiceListRequest{}, WantResponse: func() connect.AnyResponse { diff --git a/tests/e2e/admin/token_test.go b/tests/e2e/admin/token_test.go index 1393e31..13b079b 100644 --- a/tests/e2e/admin/token_test.go +++ b/tests/e2e/admin/token_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" adminv2 "github.com/metal-stack/api/go/metalstack/admin/v2" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" @@ -16,7 +17,7 @@ func Test_AdminTokenCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"admin", "token", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.TokenServiceListRequest{}, WantResponse: func() connect.AnyResponse { @@ -64,7 +65,7 @@ func Test_AdminTokenCmd_Delete(t *testing.T) { Name: "delete", CmdArgs: []string{"admin", "token", "delete", testresources.Token1().Uuid, "--user", "user-123"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &adminv2.TokenServiceRevokeRequest{ Uuid: testresources.Token1().Uuid, diff --git a/tests/e2e/api/audit_test.go b/tests/e2e/api/audit_test.go index 3743296..dfe062e 100644 --- a/tests/e2e/api/audit_test.go +++ b/tests/e2e/api/audit_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" "github.com/metal-stack/cli/tests/e2e/testresources" @@ -48,7 +49,7 @@ func Test_AuditCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"audit", "list", "--tenant", "a"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.AuditServiceListRequest{ Login: "a", @@ -100,7 +101,7 @@ func Test_AuditCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"audit", "describe", "--tenant", "a", Trace1().Uuid}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.AuditServiceGetRequest{ Login: "a", diff --git a/tests/e2e/api/health_test.go b/tests/e2e/api/health_test.go index eab32ef..1562a1e 100644 --- a/tests/e2e/api/health_test.go +++ b/tests/e2e/api/health_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" ) @@ -28,7 +29,7 @@ func Test_HealthCmd(t *testing.T) { Name: "health", CmdArgs: []string{"health"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.HealthServiceGetRequest{}, WantResponse: func() connect.AnyResponse { diff --git a/tests/e2e/api/image_test.go b/tests/e2e/api/image_test.go index f25f151..2419326 100644 --- a/tests/e2e/api/image_test.go +++ b/tests/e2e/api/image_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" "github.com/metal-stack/cli/tests/e2e/testresources" @@ -15,7 +16,7 @@ func Test_ImageCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"image", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ImageServiceListRequest{ Query: &apiv2.ImageQuery{}, @@ -66,7 +67,7 @@ func Test_ImageCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"image", "describe", testresources.Image1().Id}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ImageServiceGetRequest{ Id: testresources.Image1().Id, diff --git a/tests/e2e/api/ip_test.go b/tests/e2e/api/ip_test.go index 69985bc..d7fa668 100644 --- a/tests/e2e/api/ip_test.go +++ b/tests/e2e/api/ip_test.go @@ -5,6 +5,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" "github.com/metal-stack/cli/tests/e2e/testresources" @@ -18,7 +19,7 @@ func Test_IPCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"ip", "list", "--project", testresources.IP1().Project}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceListRequest{ Project: testresources.IP1().Project, @@ -68,7 +69,7 @@ func Test_IPCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"ip", "describe", "--project", testresources.IP1().Project, testresources.IP1().Ip}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceGetRequest{ Ip: testresources.IP1().Ip, @@ -114,7 +115,7 @@ func Test_IPCmd_Create(t *testing.T) { Name: "create", CmdArgs: []string{"ip", "create", "--project", testresources.IP1().Project, "--network", testresources.IP1().Network, "--static=true"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceCreateRequest{ Project: testresources.IP1().Project, @@ -139,7 +140,7 @@ func Test_IPCmd_Create(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.IP1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceGetRequest{ Ip: testresources.IP1().Ip, @@ -187,7 +188,7 @@ func Test_IPCmd_Delete(t *testing.T) { Name: "delete", CmdArgs: []string{"ip", "delete", "--project", testresources.IP1().Project, testresources.IP1().Ip}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceDeleteRequest{ Ip: testresources.IP1().Ip, @@ -211,7 +212,7 @@ func Test_IPCmd_Delete(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.IP1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceGetRequest{ Ip: testresources.IP1().Ip, @@ -255,7 +256,7 @@ func Test_IPCmd_Update(t *testing.T) { CmdArgs: []string{"ip", "update", "--project", testresources.IP1().Project, testresources.IP1().Ip, "--name", "foo"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ // TODO: the client gets the IP two times? { WantRequest: &apiv2.IPServiceGetRequest{ @@ -311,7 +312,7 @@ func Test_IPCmd_Update(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.IP1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceGetRequest{ Ip: testresources.IP1().Ip, @@ -364,7 +365,7 @@ func Test_IPCmd_Apply(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.IP1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceGetRequest{ Ip: testresources.IP1().Ip, @@ -409,7 +410,7 @@ func Test_IPCmd_Apply(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.IP1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.IPServiceGetRequest{ Ip: testresources.IP1().Ip, diff --git a/tests/e2e/api/project_test.go b/tests/e2e/api/project_test.go index e232912..2d748ea 100644 --- a/tests/e2e/api/project_test.go +++ b/tests/e2e/api/project_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" "github.com/metal-stack/cli/tests/e2e/testresources" @@ -17,7 +18,7 @@ func Test_ProjectCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"project", "describe", testresources.Project1().Uuid}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceGetRequest{ Project: testresources.Project1().Uuid, @@ -62,7 +63,7 @@ func Test_ProjectCmd_Create(t *testing.T) { Name: "create", CmdArgs: []string{"project", "create", "--name", testresources.Project1().Name, "--description", testresources.Project1().Description, "--tenant", testresources.Project1().Tenant}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceCreateRequest{ Login: testresources.Project1().Tenant, @@ -87,7 +88,7 @@ func Test_ProjectCmd_Create(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.Project1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceCreateRequest{ Login: testresources.Project1().Tenant, @@ -114,7 +115,7 @@ func Test_ProjectCmd_Create(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshalToMultiYAML(t, testresources.Project1(), testresources.Project2()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceCreateRequest{ Login: testresources.Project1().Tenant, @@ -159,7 +160,7 @@ func Test_ProjectCmd_Delete(t *testing.T) { Name: "delete", CmdArgs: []string{"project", "delete", testresources.Project1().Uuid}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceDeleteRequest{ Project: testresources.Project1().Uuid, @@ -181,7 +182,7 @@ func Test_ProjectCmd_Delete(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.Project1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceDeleteRequest{ Project: testresources.Project1().Uuid, @@ -211,7 +212,7 @@ func Test_ProjectCmd_Update(t *testing.T) { Name: "update", CmdArgs: []string{"project", "update", testresources.Project1().Uuid, "--name", "new-name", "--description", "new-desc"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceUpdateRequest{ Project: testresources.Project1().Uuid, @@ -235,7 +236,7 @@ func Test_ProjectCmd_Update(t *testing.T) { FsMocks: func(fs *afero.Afero) { require.NoError(t, fs.WriteFile(e2e.InputFilePath, e2e.MustMarshal(t, testresources.Project1()), 0755)) }, - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceUpdateRequest{ Project: testresources.Project1().Uuid, @@ -267,7 +268,7 @@ func Test_ProjectCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"project", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.ProjectServiceListRequest{}, WantResponse: func() connect.AnyResponse { diff --git a/tests/e2e/api/tenant_test.go b/tests/e2e/api/tenant_test.go index 01d3fb7..3936dc2 100644 --- a/tests/e2e/api/tenant_test.go +++ b/tests/e2e/api/tenant_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" "github.com/metal-stack/cli/tests/e2e/testresources" @@ -15,7 +16,7 @@ func Test_TenantCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"tenant", "describe", testresources.Tenant1().Login}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.TenantServiceGetRequest{ Login: testresources.Tenant1().Login, @@ -60,7 +61,7 @@ func Test_TenantCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"tenant", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.TenantServiceListRequest{}, WantResponse: func() connect.AnyResponse { diff --git a/tests/e2e/api/token_test.go b/tests/e2e/api/token_test.go index 45af157..d02766e 100644 --- a/tests/e2e/api/token_test.go +++ b/tests/e2e/api/token_test.go @@ -4,6 +4,7 @@ import ( "testing" "connectrpc.com/connect" + "github.com/metal-stack/api/go/client" apiv2 "github.com/metal-stack/api/go/metalstack/api/v2" "github.com/metal-stack/cli/testing/e2e" "github.com/metal-stack/cli/tests/e2e/testresources" @@ -15,7 +16,7 @@ func Test_TokenCmd_Describe(t *testing.T) { Name: "describe", CmdArgs: []string{"token", "describe", testresources.Token1().Uuid}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.TokenServiceGetRequest{ Uuid: testresources.Token1().Uuid, @@ -60,7 +61,7 @@ func Test_TokenCmd_List(t *testing.T) { Name: "list", CmdArgs: []string{"token", "list"}, NewRootCmd: e2e.NewRootCmd(t, &e2e.TestConfig{ - ClientCalls: []e2e.ClientCall{ + ClientCalls: []client.ClientCall{ { WantRequest: &apiv2.TokenServiceListRequest{}, WantResponse: func() connect.AnyResponse {