(t *testing.T)
| 105 | } |
| 106 | |
| 107 | func Test_getRun(t *testing.T) { |
| 108 | tf, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z") |
| 109 | |
| 110 | tests := []struct { |
| 111 | name string |
| 112 | opts *GetOptions |
| 113 | host string |
| 114 | httpStubs func(*httpmock.Registry) |
| 115 | jsonFields []string |
| 116 | wantOut string |
| 117 | wantErr error |
| 118 | }{ |
| 119 | { |
| 120 | name: "getting repo variable", |
| 121 | opts: &GetOptions{ |
| 122 | VariableName: "VARIABLE_ONE", |
| 123 | }, |
| 124 | host: "github.com", |
| 125 | httpStubs: func(reg *httpmock.Registry) { |
| 126 | reg.Register(httpmock.WithHost(httpmock.REST("GET", "repos/owner/repo/actions/variables/VARIABLE_ONE"), "api.github.com"), |
| 127 | httpmock.JSONResponse(shared.Variable{ |
| 128 | Value: "repo_var", |
| 129 | })) |
| 130 | }, |
| 131 | wantOut: "repo_var\n", |
| 132 | }, |
| 133 | { |
| 134 | name: "getting GHES repo variable", |
| 135 | opts: &GetOptions{ |
| 136 | VariableName: "VARIABLE_ONE", |
| 137 | }, |
| 138 | host: "example.com", |
| 139 | httpStubs: func(reg *httpmock.Registry) { |
| 140 | reg.Register(httpmock.WithHost(httpmock.REST("GET", "api/v3/repos/owner/repo/actions/variables/VARIABLE_ONE"), "example.com"), |
| 141 | httpmock.JSONResponse(shared.Variable{ |
| 142 | Value: "repo_var", |
| 143 | })) |
| 144 | }, |
| 145 | wantOut: "repo_var\n", |
| 146 | }, |
| 147 | { |
| 148 | name: "getting org variable", |
| 149 | opts: &GetOptions{ |
| 150 | OrgName: "TestOrg", |
| 151 | VariableName: "VARIABLE_ONE", |
| 152 | }, |
| 153 | host: "github.com", |
| 154 | httpStubs: func(reg *httpmock.Registry) { |
| 155 | reg.Register(httpmock.REST("GET", "orgs/TestOrg/actions/variables/VARIABLE_ONE"), |
| 156 | httpmock.JSONResponse(shared.Variable{ |
| 157 | Value: "org_var", |
| 158 | })) |
| 159 | }, |
| 160 | wantOut: "org_var\n", |
| 161 | }, |
| 162 | { |
| 163 | name: "getting env variable", |
| 164 | opts: &GetOptions{ |
nothing calls this directly
no test coverage detected