github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/migrate/testing/fixtures.go (about)

     1  package testing
     2  
     3  import (
     4  	"net/http"
     5  	"testing"
     6  
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func mockMigrateResponse(t *testing.T, id string) {
    12  	th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) {
    13  		th.TestMethod(t, r, "POST")
    14  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
    15  		th.TestJSONRequest(t, r, `{"migrate": null}`)
    16  		w.WriteHeader(http.StatusAccepted)
    17  	})
    18  }
    19  
    20  func mockLiveMigrateResponse(t *testing.T, id string) {
    21  	th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) {
    22  		th.TestMethod(t, r, "POST")
    23  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
    24  		th.TestJSONRequest(t, r, `{
    25  			"os-migrateLive": {
    26  				"host": "01c0cadef72d47e28a672a76060d492c",
    27  				"block_migration": false,
    28  				"disk_over_commit": true
    29  			}
    30  		}`)
    31  		w.WriteHeader(http.StatusAccepted)
    32  	})
    33  }