(t *testing.T)
| 711 | } |
| 712 | |
| 713 | func 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 | |
| 760 | func createFakeEditPendingOpServer() *httptest.Server { |
| 761 | return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected