Add createdAt field to tests

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>
This commit is contained in:
Babak K. Shandiz 2024-05-26 00:05:23 +01:00
parent 94dff4de04
commit 4aa6f8f2f3
No known key found for this signature in database
GPG key ID: 44950AED81AD710F
2 changed files with 7 additions and 3 deletions

View file

@ -161,13 +161,14 @@ func Test_getRun(t *testing.T) {
opts: &GetOptions{
VariableName: "VARIABLE_ONE",
},
jsonFields: []string{"name", "value", "visibility", "updatedAt", "numSelectedRepos", "selectedReposURL"},
jsonFields: []string{"name", "value", "visibility", "updatedAt", "createdAt", "numSelectedRepos", "selectedReposURL"},
httpStubs: func(reg *httpmock.Registry) {
reg.Register(httpmock.REST("GET", "repos/owner/repo/actions/variables/VARIABLE_ONE"),
httpmock.JSONResponse(shared.Variable{
Name: "VARIABLE_ONE",
Value: "repo_var",
UpdatedAt: tf,
CreatedAt: tf,
Visibility: shared.Organization,
SelectedReposURL: "path/to/fetch/selected/repos",
NumSelectedRepos: 0, // This should be populated in a second API call.
@ -181,6 +182,7 @@ func Test_getRun(t *testing.T) {
"name": "VARIABLE_ONE",
"value": "repo_var",
"updatedAt": "2024-01-01T00:00:00Z",
"createdAt": "2024-01-01T00:00:00Z",
"visibility": "organization",
"selectedReposURL": "path/to/fetch/selected/repos",
"numSelectedRepos": 99
@ -266,6 +268,7 @@ func TestExportVariables(t *testing.T) {
Name: "v1",
Value: "test1",
UpdatedAt: tf,
CreatedAt: tf,
Visibility: shared.All,
SelectedReposURL: "https://someurl.com",
NumSelectedRepos: 1,
@ -274,6 +277,6 @@ func TestExportVariables(t *testing.T) {
exporter.SetFields(shared.VariableJSONFields)
require.NoError(t, exporter.Write(ios, vs))
require.JSONEq(t,
`{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}`,
`{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","createdAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}`,
stdout.String())
}

View file

@ -331,6 +331,7 @@ func TestExportVariables(t *testing.T) {
Name: "v1",
Value: "test1",
UpdatedAt: tf,
CreatedAt: tf,
Visibility: shared.All,
SelectedReposURL: "https://someurl.com",
NumSelectedRepos: 1,
@ -339,6 +340,6 @@ func TestExportVariables(t *testing.T) {
exporter.SetFields(shared.VariableJSONFields)
require.NoError(t, exporter.Write(ios, vs))
require.JSONEq(t,
`[{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}]`,
`[{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","createdAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}]`,
stdout.String())
}