MCPcopy Index your code
hub / github.com/cli/cli / createFakeEditServer

Function createFakeEditServer

internal/codespaces/api/api_test.go:675–711  ·  view source on GitHub ↗
(t *testing.T, codespaceName string)

Source from the content-addressed store, hash-verified

673}
674
675func createFakeEditServer(t *testing.T, codespaceName string) *httptest.Server {
676 return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
677 checkPath := "/user/codespaces/" + codespaceName
678
679 if r.URL.Path != checkPath {
680 t.Fatal("Incorrect path")
681 }
682
683 if r.Method != http.MethodPatch {
684 t.Fatal("Incorrect method")
685 }
686
687 body := r.Body
688 if body == nil {
689 t.Fatal("No body")
690 }
691 defer body.Close()
692
693 var data map[string]interface{}
694 err := json.NewDecoder(body).Decode(&data)
695
696 if err != nil {
697 t.Fatal(err)
698 }
699
700 if data["display_name"] != "changeTo" {
701 t.Fatal("Incorrect display name")
702 }
703
704 response := Codespace{
705 DisplayName: "changeTo",
706 }
707
708 responseData, _ := json.Marshal(response)
709 fmt.Fprint(w, string(responseData))
710 }))
711}
712
713func TestAPI_EditCodespace(t *testing.T) {
714 type args struct {

Callers 1

TestAPI_EditCodespaceFunction · 0.85

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected