diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index b11061eb..7455cfa7 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -34,7 +34,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Generate cli docs working-directory: cli diff --git a/.github/workflows/go-releaser.yml b/.github/workflows/go-releaser.yml index 9b3e9f09..34087a03 100644 --- a/.github/workflows/go-releaser.yml +++ b/.github/workflows/go-releaser.yml @@ -28,7 +28,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - uses: crazy-max/ghaction-import-gpg@v5 id: import_gpg diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index cbdc4b62..a6cfc53b 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -50,7 +50,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 - name: Setup gotestsum run: go install gotest.tools/gotestsum@latest diff --git a/.github/workflows/pr-validation.yml b/.github/workflows/pr-validation.yml index f60c7271..2813267f 100644 --- a/.github/workflows/pr-validation.yml +++ b/.github/workflows/pr-validation.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.21 # if we just run the unit tests then go doesn't compile the parts of the app that aren't covered by # unit tests; this forces it diff --git a/go.mod b/go.mod index 2e37fe63..29e32111 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/OctopusDeploy/cli -go 1.19 +go 1.21 require ( github.com/AlecAivazis/survey/v2 v2.3.6 diff --git a/go.sum b/go.sum index 0d1f9554..df48efe3 100644 --- a/go.sum +++ b/go.sum @@ -77,12 +77,14 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -126,6 +128,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= @@ -171,13 +174,16 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/kinbiko/jsonassert v1.1.1 h1:DB12divY+YB+cVpHULLuKePSi6+ui4M/shHSzJISkSE= +github.com/kinbiko/jsonassert v1.1.1/go.mod h1:NO4lzrogohtIdNUNzx8sdzB55M4R4Q1bsrWVdqQ7C+A= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= @@ -218,6 +224,7 @@ github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= @@ -550,6 +557,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/pkg/apiclient/apiclient_test.go b/pkg/apiclient/apiclient_test.go index a19b6d16..b1607c99 100644 --- a/pkg/apiclient/apiclient_test.go +++ b/pkg/apiclient/apiclient_test.go @@ -29,9 +29,10 @@ func TestClient_GetSystemClient(t *testing.T) { func() (*octopusApiClient.Client, error) { return factory.GetSystemClient(&apiclient.FakeRequesterContext{}) }) - //clientReceiver2 := testutil.GoBegin2(func () (*octopusApiClient.Client, error) { factory.GetSystemClient(&apiclient.FakeRequesterContext{}) + //clientReceiver2 := testutil.GoBegin2(func () (*octopusApiClient.Client, error) { factory.GetSystemClient(&apiclient.FakeRequesterContext{}) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) systemClient, err := testutil.ReceivePair(clientReceiver) if !testutil.AssertSuccess(t, err) { @@ -51,6 +52,7 @@ func TestClient_GetSystemClient(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) systemClient, err := testutil.ReceivePair(clientReceiver) if !testutil.AssertSuccess(t, err) { @@ -77,6 +79,7 @@ func TestClient_GetSystemClient(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").ExpectHeader(t, "Authorization", "Bearer token").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) systemClient, err := testutil.ReceivePair(clientReceiver) if !testutil.AssertSuccess(t, err) { @@ -113,6 +116,8 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) + //api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith(root) // it doesn't actually matter how many spaces there are because the CLI doesn't even ask for them apiClient, err := testutil.ReceivePair(clientReceiver) @@ -131,6 +136,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{cloudSpace}) @@ -150,6 +156,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{integrationsSpace}) @@ -175,6 +182,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{integrationsSpace}) @@ -200,6 +208,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{integrationsSpace}) @@ -225,6 +234,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{integrationsSpace}) @@ -256,6 +266,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{ missedSpace, @@ -283,6 +294,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").RespondWith([]*spaces.Space{integrationsSpace}) @@ -315,6 +327,7 @@ func TestClient_GetSpacedClient_NoPrompt(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").ExpectHeader(t, "Authorization", "Bearer token").RespondWith(root) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(root) api.ExpectRequest(t, "GET", "/api/spaces/all").ExpectHeader(t, "Authorization", "Bearer token").RespondWith([]*spaces.Space{integrationsSpace}) diff --git a/pkg/cmd/account/aws/create/create_test.go b/pkg/cmd/account/aws/create/create_test.go index 62fc79b1..fbf35e36 100644 --- a/pkg/cmd/account/aws/create/create_test.go +++ b/pkg/cmd/account/aws/create/create_test.go @@ -52,6 +52,7 @@ func TestAWSAccountCreatePromptMissing(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Name", @@ -129,6 +130,7 @@ func TestAWSAccountCreateNoPrompt(t *testing.T) { testAccount.SpaceID = spaceID api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "POST", "/api/Spaces-1/accounts").RespondWithStatus(201, "", testAccount) err = <-errReceiver diff --git a/pkg/cmd/account/azure/create/create_test.go b/pkg/cmd/account/azure/create/create_test.go index 02b967df..c815798a 100644 --- a/pkg/cmd/account/azure/create/create_test.go +++ b/pkg/cmd/account/azure/create/create_test.go @@ -54,6 +54,7 @@ func TestAzureAccountCreatePromptMissing(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Name", @@ -71,7 +72,7 @@ func TestAzureAccountCreatePromptMissing(t *testing.T) { _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Subscription ID", - Help: "Your Azure subscription ID. This is a GUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.", + Help: "Your Azure Subscription ID. This is a GUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.", }).AnswerWith("d2486c05-0cac-4d54-a91e-654043036f31") _ = qa.ExpectQuestion(t, &survey.Input{ @@ -81,7 +82,7 @@ func TestAzureAccountCreatePromptMissing(t *testing.T) { _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Application ID", - Help: "Your Azure Active Directory Tenant ID. This is a GUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.", + Help: "Your Azure Active Directory Application ID. This is a GUID in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.", }).AnswerWith("d2486c05-0cac-4d54-a91e-654043036f33") _ = qa.ExpectQuestion(t, &survey.Password{ @@ -155,6 +156,7 @@ func TestAzureAccountCreateNoPrompt(t *testing.T) { testAccount.SpaceID = spaceID api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "POST", "/api/Spaces-1/accounts").RespondWithStatus(201, "", testAccount) err = <-errReceiver diff --git a/pkg/cmd/account/gcp/create/create_test.go b/pkg/cmd/account/gcp/create/create_test.go index 39d867fc..2c771e6a 100644 --- a/pkg/cmd/account/gcp/create/create_test.go +++ b/pkg/cmd/account/gcp/create/create_test.go @@ -55,6 +55,7 @@ func TestGCPAccountCreatePromptMissing(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Name", @@ -118,6 +119,7 @@ func TestGCPAccountCreateNoPrompt(t *testing.T) { testAccount.SpaceID = spaceID api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "POST", "/api/Spaces-1/accounts").RespondWithStatus(201, "", testAccount) err = <-errReceiver diff --git a/pkg/cmd/account/ssh/create/create_test.go b/pkg/cmd/account/ssh/create/create_test.go index 19b2ed86..ded833dc 100644 --- a/pkg/cmd/account/ssh/create/create_test.go +++ b/pkg/cmd/account/ssh/create/create_test.go @@ -56,6 +56,7 @@ func TestGCPAccountCreatePromptMissing(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Name", @@ -137,6 +138,7 @@ func TestGCPAccountCreateNoPrompt(t *testing.T) { testAccount.PrivateKeyPassphrase = core.NewSensitiveValue(opts.Passphrase.Value) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "POST", "/api/Spaces-1/accounts").RespondWithStatus(201, "", testAccount) err = <-errReceiver diff --git a/pkg/cmd/account/token/create/create_test.go b/pkg/cmd/account/token/create/create_test.go index 5988ddac..16db521e 100644 --- a/pkg/cmd/account/token/create/create_test.go +++ b/pkg/cmd/account/token/create/create_test.go @@ -52,6 +52,7 @@ func TestTokenAccountCreatePromptMissing(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Name", @@ -121,6 +122,7 @@ func TestTokenAccountCreateNoPrompt(t *testing.T) { testAccount.SpaceID = spaceID api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "POST", "/api/Spaces-1/accounts").RespondWithStatus(201, "", testAccount) err = <-errReceiver diff --git a/pkg/cmd/account/username/create/create_test.go b/pkg/cmd/account/username/create/create_test.go index c3dc57b9..0ceefae1 100644 --- a/pkg/cmd/account/username/create/create_test.go +++ b/pkg/cmd/account/username/create/create_test.go @@ -52,6 +52,7 @@ func TestUsernameAccountCreatePromptMissing(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) _ = qa.ExpectQuestion(t, &survey.Input{ Message: "Name", @@ -127,6 +128,7 @@ func TestUsernameAccountCreateNoPrompt(t *testing.T) { testAccount.Password = core.NewSensitiveValue("password123") api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "POST", "/api/Spaces-1/accounts").RespondWithStatus(201, "", testAccount) err = <-errReceiver diff --git a/pkg/cmd/release/create/create_test.go b/pkg/cmd/release/create/create_test.go index 0b6df48d..15798bbd 100644 --- a/pkg/cmd/release/create/create_test.go +++ b/pkg/cmd/release/create/create_test.go @@ -65,6 +65,7 @@ func TestReleaseCreate_AskQuestions_RegularProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/all").RespondWith([]*projects.Project{fireProject}) @@ -128,6 +129,7 @@ func TestReleaseCreate_AskQuestions_RegularProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -170,6 +172,7 @@ func TestReleaseCreate_AskQuestions_RegularProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -252,6 +255,7 @@ func TestReleaseCreate_AskQuestions_RegularProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) var fireProject2 = *fireProject // clone the struct value fireProject2.VersioningStrategy = &projects.VersioningStrategy{ @@ -362,6 +366,7 @@ func TestReleaseCreate_AskQuestions_RegularProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) var fireProject2 = *fireProject // clone the struct value fireProject2.VersioningStrategy = &projects.VersioningStrategy{ @@ -471,6 +476,7 @@ func TestReleaseCreate_AskQuestions_VersionControlledProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/all").RespondWith([]*projects.Project{project}) @@ -558,6 +564,7 @@ func TestReleaseCreate_AskQuestions_VersionControlledProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/all").RespondWith([]*projects.Project{project}) @@ -641,6 +648,7 @@ func TestReleaseCreate_AskQuestions_VersionControlledProject(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/all").RespondWith([]*projects.Project{project}) @@ -1806,6 +1814,7 @@ func TestReleaseCreate_BuildPackageVersionBaseline(t *testing.T) { // octopusApiClient.NewClient fetches the root resource but otherwise BuildPackageVersionBaseline does nothing api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) packageVersions, err := testutil.ReceivePair(receiver) assert.Nil(t, err) @@ -1836,6 +1845,7 @@ func TestReleaseCreate_BuildPackageVersionBaseline(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) // it needs to load the feeds to find the links api.ExpectRequest(t, "GET", "/api/Spaces-1/feeds?ids=feeds-builtin&take=1").RespondWith(&feeds.Feeds{Items: []feeds.IFeed{ @@ -1910,6 +1920,7 @@ func TestReleaseCreate_BuildPackageVersionBaseline(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) // it needs to load the feeds to find the links api.ExpectRequest(t, "GET", "/api/Spaces-1/feeds?ids=Feeds-1001&ids=feeds-builtin&take=2").RespondWith(&feeds.Feeds{Items: []feeds.IFeed{ @@ -2032,6 +2043,7 @@ func TestReleaseCreate_BuildPackageVersionBaseline(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) // it needs to load the feeds to find the links api.ExpectRequest(t, "GET", "/api/Spaces-1/feeds?ids=Feeds-1001&ids=feeds-builtin&take=2").RespondWith(&feeds.Feeds{Items: []feeds.IFeed{ @@ -2117,6 +2129,7 @@ func TestReleaseCreate_BuildPackageVersionBaseline(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) // it needs to load the feeds to find the links api.ExpectRequest(t, "GET", "/api/Spaces-1/feeds?ids=feeds-builtin&take=1").RespondWith(&feeds.Feeds{Items: []feeds.IFeed{ @@ -2174,6 +2187,7 @@ func TestReleaseCreate_BuildPackageVersionBaseline(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) // it needs to load the feeds to find the links api.ExpectRequest(t, "GET", "/api/Spaces-1/feeds?ids=feeds-builtin&take=1").RespondWith(&feeds.Feeds{Items: []feeds.IFeed{ diff --git a/pkg/cmd/release/deploy/deploy_test.go b/pkg/cmd/release/deploy/deploy_test.go index 12f3f956..6dcb1230 100644 --- a/pkg/cmd/release/deploy/deploy_test.go +++ b/pkg/cmd/release/deploy/deploy_test.go @@ -124,6 +124,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { panic("you must set `options.ReleaseVersion` to match the supplied `release.Version`") } api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/"+options.ProjectName).RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName="+url.QueryEscape(options.ProjectName)). @@ -151,6 +152,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/all").RespondWith([]*projects.Project{fireProject}) @@ -238,6 +240,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -297,6 +300,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -360,6 +364,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -454,6 +459,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -552,6 +558,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/fire project").RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName=fire+project"). @@ -739,6 +746,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) { }) api.ExpectRequest(t, "GET", "/api").RespondWith(rootResource) + api.ExpectRequest(t, "GET", "/api/spaces").RespondWith(rootResource) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects/"+options.ProjectName).RespondWithStatus(404, "NotFound", nil) api.ExpectRequest(t, "GET", "/api/Spaces-1/projects?partialName="+url.QueryEscape(options.ProjectName)). diff --git a/test/integration/release_test.go b/test/integration/release_test.go index 80b12b0d..b6f476f3 100644 --- a/test/integration/release_test.go +++ b/test/integration/release_test.go @@ -211,7 +211,7 @@ func TestReleaseListAndDelete(t *testing.T) { } // create some releases so we can list them - createReleaseCmd := releases.NewCreateReleaseCommandV1(space1ID, fx.Project.ID) + createReleaseCmd := releases.NewCreateReleaseCommandV1(space1ID, fx.Project.GetName()) for i := 0; i < 5; i++ { createReleaseCmd.ReleaseVersion = fmt.Sprintf("%d.0", i+1) _, err := releases.CreateReleaseV1(apiClient, createReleaseCmd) diff --git a/test/testutil/fakesurvey.go b/test/testutil/fakesurvey.go index 21540ee9..4afb99f6 100644 --- a/test/testutil/fakesurvey.go +++ b/test/testutil/fakesurvey.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "github.com/OctopusDeploy/cli/pkg/surveyext" + "slices" "testing" "github.com/AlecAivazis/survey/v2" @@ -165,7 +166,13 @@ func NewMockAsker(t *testing.T, pa []*PA) (question.Asker, CheckRemaining) { } expectedQA := pa[expectedQuestionIndex] - expectedQuestionIndex += 1 + expectedQuestionIndex++ + + if expectedSurvey, ok := expectedQA.Prompt.(*survey.Select); ok { + actualSurvey := p.(*survey.Select) + slices.Sort(expectedSurvey.Options) + slices.Sort(actualSurvey.Options) + } isEqual := assert.Equal(t, expectedQA.Prompt, p) if !isEqual {