(t *testing.T, codespaceName string)
| 673 | } |
| 674 | |
| 675 | func 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 | |
| 713 | func TestAPI_EditCodespace(t *testing.T) { |
| 714 | type args struct { |
no test coverage detected