@@ -106,3 +106,35 @@ func TestListQueryParametersAreNotEscapedIntoPath(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimePricingAndInstanceEIPOperations(t *testing.T) {
|
||||
paths := []string{}
|
||||
client, _ := testClient(t, func(w http.ResponseWriter, r *http.Request) {
|
||||
paths = append(paths, r.Method+" "+r.URL.Path)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
if r.URL.Path == "/api/sdk/v1/regions/us-east-1/instances/local-1/price-estimate" {
|
||||
_, _ = w.Write([]byte(`{"code":200,"message":"Success","data":{"currency":"USD","monthly_price":12.5,"configuration_fingerprint":"fingerprint"}}`))
|
||||
return
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"code":202,"message":"Accepted","data":{"task_id":"task-1","status":"queued"}}`))
|
||||
})
|
||||
estimate, err := client.Pricing.EstimateExistingInstance(context.Background(), "us-east-1", "local-1")
|
||||
if err != nil || estimate.ConfigurationFingerprint != "fingerprint" || estimate.MonthlyPrice != 12.5 {
|
||||
t.Fatalf("estimate=%#v err=%v", estimate, err)
|
||||
}
|
||||
if _, err := client.EIPs.Disassociate(context.Background(), "us-east-1", "local-1", WithIdempotencyKey("disassociate")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := client.EIPs.Release(context.Background(), "us-east-1", "local-1", WithIdempotencyKey("release")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
want := []string{"POST /api/sdk/v1/regions/us-east-1/instances/local-1/price-estimate", "POST /api/sdk/v1/regions/us-east-1/instances/local-1/eip/disassociate", "DELETE /api/sdk/v1/regions/us-east-1/instances/local-1/eip"}
|
||||
if len(paths) != len(want) {
|
||||
t.Fatalf("paths=%v", paths)
|
||||
}
|
||||
for i := range want {
|
||||
if paths[i] != want[i] {
|
||||
t.Fatalf("paths=%v want=%v", paths, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user