From 25309f38d8d017ce7a6305842ed0b40b72e4a59e Mon Sep 17 00:00:00 2001 From: Julien Midedji Date: Sun, 1 Oct 2023 19:15:41 +0200 Subject: [PATCH] Add test for resource JSON marshaling - ActionVariable (#2942) --- github/actions_variables_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/github/actions_variables_test.go b/github/actions_variables_test.go index 646da92b1e8..a9f773c261e 100644 --- a/github/actions_variables_test.go +++ b/github/actions_variables_test.go @@ -657,3 +657,31 @@ func TestActionsService_DeleteEnvVariable(t *testing.T) { return client.Actions.DeleteEnvVariable(ctx, 1, "r", "variable") }) } + +func TestActionVariable_Marshal(t *testing.T) { + testJSONMarshal(t, &ActionsVariable{}, "{}") + + av := &ActionsVariable{ + Name: "n", + Value: "v", + CreatedAt: &Timestamp{referenceTime}, + UpdatedAt: &Timestamp{referenceTime}, + Visibility: String("v"), + SelectedRepositoriesURL: String("s"), + SelectedRepositoryIDs: &SelectedRepoIDs{1, 2, 3}, + } + + want := fmt.Sprintf(`{ + "name": "n", + "value": "v", + "created_at": %s, + "updated_at": %s, + "visibility": "v", + "selected_repositories_url": "s", + "selected_repository_ids": [1,2,3] + }`, referenceTimeStr, referenceTimeStr) + + fmt.Println(want) + + testJSONMarshal(t, av, want) +}