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

Function TestAPI_EditCodespace

internal/codespaces/api/api_test.go:713–758  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

711}
712
713func TestAPI_EditCodespace(t *testing.T) {
714 type args struct {
715 ctx context.Context
716 codespaceName string
717 params *EditCodespaceParams
718 }
719 tests := []struct {
720 name string
721 args args
722 want *Codespace
723 wantErr bool
724 }{
725 {
726 name: "success",
727 args: args{
728 ctx: context.Background(),
729 codespaceName: "test",
730 params: &EditCodespaceParams{
731 DisplayName: "changeTo",
732 },
733 },
734 want: &Codespace{
735 DisplayName: "changeTo",
736 },
737 },
738 }
739 for _, tt := range tests {
740 t.Run(tt.name, func(t *testing.T) {
741 svr := createFakeEditServer(t, tt.args.codespaceName)
742 defer svr.Close()
743
744 a := &API{
745 client: createHttpClient,
746 githubAPI: svr.URL,
747 }
748 got, err := a.EditCodespace(tt.args.ctx, tt.args.codespaceName, tt.args.params)
749 if (err != nil) != tt.wantErr {
750 t.Errorf("API.EditCodespace() error = %v, wantErr %v", err, tt.wantErr)
751 return
752 }
753 if !reflect.DeepEqual(got, tt.want) {
754 t.Errorf("API.EditCodespace() = %v, want %v", got.DisplayName, tt.want.DisplayName)
755 }
756 })
757 }
758}
759
760func createFakeEditPendingOpServer() *httptest.Server {
761 return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 5

EditCodespaceMethod · 0.95
createFakeEditServerFunction · 0.85
RunMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected