MCPcopy Create free account
hub / github.com/cli/cli / TestGetTrustDomain

Function TestGetTrustDomain

pkg/cmd/attestation/api/client_test.go:324–354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

322}
323
324func TestGetTrustDomain(t *testing.T) {
325 fetcher := mockMetaGenerator{
326 TrustDomain: "foo",
327 }
328
329 t.Run("with returned trust domain", func(t *testing.T) {
330 c := LiveClient{
331 githubAPI: mockAPIClient{
332 OnREST: fetcher.OnREST,
333 },
334 logger: io.NewTestHandler(),
335 }
336 td, err := c.GetTrustDomain()
337 require.Nil(t, err)
338 require.Equal(t, "foo", td)
339
340 })
341
342 t.Run("with error", func(t *testing.T) {
343 c := LiveClient{
344 githubAPI: mockAPIClient{
345 OnREST: fetcher.OnRESTError,
346 },
347 logger: io.NewTestHandler(),
348 }
349 td, err := c.GetTrustDomain()
350 require.Equal(t, "", td)
351 require.ErrorContains(t, err, "test error")
352 })
353
354}
355
356func TestGetAttestationsRetries(t *testing.T) {
357 getAttestationRetryInterval = 0

Callers

nothing calls this directly

Calls 4

GetTrustDomainMethod · 0.95
NewTestHandlerFunction · 0.92
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected