Skip to content

Commit 1c7be12

Browse files
authored
fix: tests (#416)
1 parent fcda660 commit 1c7be12

6 files changed

Lines changed: 24 additions & 9 deletions

File tree

cmd/cloudx/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/spf13/cobra"
1111

12-
hydra "github.com/ory/hydra-client-go/v26"
12+
hydra "github.com/ory/hydra-client-go/v2"
1313
hydracli "github.com/ory/hydra/v2/cmd/cliclient"
1414
kratoscli "github.com/ory/kratos/cmd/cliclient"
1515
)

cmd/cloudx/client/command_helper_setup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestDetermineIDs(t *testing.T) {
6161
setup := func(t *testing.T) (*CommandHelper, *Config) {
6262
h := &CommandHelper{
6363
configLocation: t.TempDir() + "/config.json",
64-
cloudConsoleAPIURL: new(ts.URL),
64+
cloudConsoleAPIURL: &ts.URL,
6565
}
6666
cfg, err := h.getOrCreateConfig()
6767
require.NoError(t, err)

cmd/cloudx/client/fixtures/update_project/config.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,5 @@
396396
]
397397
}
398398
}
399-
},
400-
"slug": "pensive-darwin-upz1f31srv",
401-
"state": "running"
399+
}
402400
}

cmd/cloudx/relationtuples/relationtuples.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,37 @@ func NewDeleteCmd() *cobra.Command {
4141
func NewCreateCmd() *cobra.Command {
4242
cmd := relationtuple.NewCreateCmd()
4343
wrapForOryCLI(cmd)
44+
wrapForStdinArg(cmd)
4445

4546
return cmd
4647
}
4748

4849
func NewParseCmd() *cobra.Command {
4950
cmd := relationtuple.NewParseCmd()
5051
wrapForOryCLI(cmd)
52+
// The keto parse command uses cobra.NoArgs; allow one optional arg so
53+
// callers can pass "-" for stdin (translated to -f - below).
54+
cmd.Args = cobra.MaximumNArgs(1)
55+
wrapForStdinArg(cmd)
5156

5257
return cmd
5358
}
5459

60+
// wrapForStdinArg translates a bare "-" positional argument into the -f flag
61+
// expected by the keto commands for reading from stdin.
62+
func wrapForStdinArg(cmd *cobra.Command) {
63+
originalRunE := cmd.RunE
64+
cmd.RunE = func(cmd *cobra.Command, args []string) error {
65+
if len(args) == 1 && args[0] == "-" {
66+
if err := cmd.Flags().Set(relationtuple.FlagFile, "-"); err != nil {
67+
return err
68+
}
69+
args = args[:0]
70+
}
71+
return originalRunE(cmd, args)
72+
}
73+
}
74+
5575
func forwardConnectionInfo(cmd *cobra.Command) {
5676
originalRunE := cmd.RunE
5777
cmd.RunE = func(cmd *cobra.Command, args []string) error {

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ require (
2525
github.com/ory/gochimp3 v0.0.0-20200417124117-ccd242db3655
2626
github.com/ory/graceful v0.1.4-0.20230301144740-e222150c51d0
2727
github.com/ory/herodot v0.10.8
28-
github.com/ory/hydra-client-go/v26 v26.2.0
28+
github.com/ory/hydra-client-go/v2 v2.4.0-alpha.1.0.20251107123905-f3d35665821b
2929
github.com/ory/hydra/v2 v2.3.1-0.20260324164235-735e0a30f7f2
3030
github.com/ory/jsonschema/v3 v3.0.9-0.20250317235931-280c5fc7bf0e
3131
github.com/ory/keto v0.14.1-0.20260324164236-ccb79cfc480c
@@ -214,7 +214,6 @@ require (
214214
github.com/ory/dockertest/v4 v4.0.0-beta.4 // indirect
215215
github.com/ory/go-acc v0.2.9-0.20230103102148-6b1c9a70dbbe // indirect
216216
github.com/ory/go-convenience v0.1.0 // indirect
217-
github.com/ory/hydra-client-go/v2 v2.4.0-alpha.1.0.20251107123905-f3d35665821b // indirect
218217
github.com/ory/keto/proto v0.13.0-alpha.0 // indirect
219218
github.com/ory/kratos-client-go v1.3.8 // indirect
220219
github.com/ory/mail/v3 v3.0.0 // indirect

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,6 @@ github.com/ory/herodot v0.10.8 h1:uUPsXd4FKTsNHHU+OS5gYrRNEMraU36st0kBeWiXsno=
570570
github.com/ory/herodot v0.10.8/go.mod h1:j6i246U6iX8TStYNKIVQxb2waweQvtOLi+b/9q+OULg=
571571
github.com/ory/hydra-client-go/v2 v2.4.0-alpha.1.0.20251107123905-f3d35665821b h1:2mfIv+P6sCUIEVNgGCrj0EBtyxudxXIoGdYBk6V7HMo=
572572
github.com/ory/hydra-client-go/v2 v2.4.0-alpha.1.0.20251107123905-f3d35665821b/go.mod h1:7jEdxEF8ZgjU3PJ4yGvSGv7nptAvMeuX2EQdfHxKOGo=
573-
github.com/ory/hydra-client-go/v26 v26.2.0 h1:el+M6dV5CK3Am2V4isorOoZ8pJdDaJm0irQzqnxZHqU=
574-
github.com/ory/hydra-client-go/v26 v26.2.0/go.mod h1:IkTtqWmwQoFGo6dclIP2n51uror2sGNHC4Fjs/QlFqM=
575573
github.com/ory/hydra/v2 v2.3.1-0.20260324164235-735e0a30f7f2 h1:yhlIEHGmXnz/NzBYMVzv+iLIVBdN+O3LsuEJawum/NA=
576574
github.com/ory/hydra/v2 v2.3.1-0.20260324164235-735e0a30f7f2/go.mod h1:y8UC1QH4TybEy/B/sHxMx9qnjxF1OtXrVPEnC9ErzyY=
577575
github.com/ory/jsonschema/v3 v3.0.9-0.20250317235931-280c5fc7bf0e h1:4tUrC7x4YWRVMFp+c64KACNSGchW1zXo4l6Pa9/1hA8=

0 commit comments

Comments
 (0)