Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson committed Jan 6, 2025
1 parent cf8b041 commit 69a675b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/credentials/github_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package credentials_test

import (
"encoding/json"
"fmt"
"testing"

"github.com/OctopusDeploy/go-octopusdeploy/v2/internal"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/credentials"
"github.com/kinbiko/jsonassert"
"github.com/stretchr/testify/require"
)

func TestGitHubMarshalJSON(t *testing.T) {
id := internal.GetRandomName()
reference := credentials.NewGitHub(id)

referenceAsJSON, err := json.Marshal(reference)
require.NoError(t, err)
require.NotNil(t, referenceAsJSON)

expectedJSON := fmt.Sprintf(`{
"Id": "%s",
"Type": "%s"
}`, id, credentials.GitCredentialTypeGitHub)

jsonassert.New(t).Assertf(expectedJSON, string(referenceAsJSON))
}

0 comments on commit 69a675b

Please sign in to comment.