github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/lockunlock/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 mockStartServerResponse(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, `{"lock": null}`)
    16  		w.WriteHeader(http.StatusAccepted)
    17  	})
    18  }
    19  
    20  func mockStopServerResponse(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, `{"unlock": null}`)
    25  		w.WriteHeader(http.StatusAccepted)
    26  	})
    27  }