Skip to content

Commit

Permalink
Merge branch 'main' into release-please--branches--main--components--…
Browse files Browse the repository at this point in the history
…fireactions
  • Loading branch information
konradasb authored Nov 27, 2024
2 parents c088725 + 9ba5a10 commit 690c702
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
16 changes: 12 additions & 4 deletions commands/pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ func TestPoolsScaleCommand_Success(t *testing.T) {
client = mockClient

cmd := newPoolsScaleCmd()
cmd.Flags().Set("replicas", "1")
err := newPoolsScaleCmd().RunE(cmd, []string{"pool-name", "1"})
err := cmd.Flags().Set("replicas", "1")
if err != nil {
t.Fatal(err)
}

err = newPoolsScaleCmd().RunE(cmd, []string{"pool-name", "1"})
assert.Nil(t, err)
}

Expand All @@ -85,8 +89,12 @@ func TestPoolsScaleCommand_Failure(t *testing.T) {
client = mockClient

cmd := newPoolsScaleCmd()
cmd.Flags().Set("replicas", "1")
err := cmd.RunE(cmd, []string{"pool-name"})
err := cmd.Flags().Set("replicas", "1")
if err != nil {
t.Fatal(err)
}

err = cmd.RunE(cmd, []string{"pool-name"})
assert.Error(t, err)
}

Expand Down
20 changes: 16 additions & 4 deletions runner/mmds/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ func TestClient_GetMetadata_Success(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPut && r.URL.Path == "/latest/api/token" {
w.WriteHeader(http.StatusOK)
w.Write([]byte("mock-token"))
_, err := w.Write([]byte("mock-token"))
if err != nil {
t.Fatal(err)
}
} else if r.Method == http.MethodGet && r.URL.Path == "/latest/meta-data/test" {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"key": "value"}`))
_, err := w.Write([]byte(`{"key": "value"}`))
if err != nil {
t.Fatal(err)
}
} else {
w.WriteHeader(http.StatusNotFound)
}
Expand All @@ -51,7 +57,10 @@ func TestClient_GetMetadata_Unauthorized(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPut && r.URL.Path == "/latest/api/token" {
w.WriteHeader(http.StatusOK)
w.Write([]byte("mock-token"))
_, err := w.Write([]byte("mock-token"))
if err != nil {
t.Fatal(err)
}
} else if r.Method == http.MethodGet && r.URL.Path == "/latest/meta-data/test" {
w.WriteHeader(http.StatusUnauthorized)
} else {
Expand All @@ -70,7 +79,10 @@ func TestClient_GetMetadata_Unknown(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPut && r.URL.Path == "/latest/api/token" {
w.WriteHeader(http.StatusOK)
w.Write([]byte("mock-token"))
_, err := w.Write([]byte("mock-token"))
if err != nil {
t.Fatal(err)
}
} else if r.Method == http.MethodGet && r.URL.Path == "/latest/meta-data/test" {
w.WriteHeader(http.StatusInternalServerError)
} else {
Expand Down

0 comments on commit 690c702

Please sign in to comment.