Skip to content

Commit

Permalink
adjust Base64String
Browse files Browse the repository at this point in the history
Make a few minor changes:

• sort Base64String alphabetically
	For consistency.
• change underlying type of Base64String to string
	This is similar to how githubv4.GitObjectID or githubv4.HTML
	use a string rather than graphql.String. The pattern is that
	named graphql types are used for equivalent types in githubv4,
	otherwise basic types are used.
• add a test case for NewBase64String in TestNewScalars
	For consistency.
  • Loading branch information
dmitshur committed Sep 22, 2021
1 parent deaabea commit 54eb371
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scalar.go
Expand Up @@ -20,12 +20,12 @@ import (
// is resolved, native Go types can completely replace these.

type (
// Base64String is a (potentially binary) string encoded using base64.
Base64String string

// Boolean represents true or false values.
Boolean graphql.Boolean

// Base64String is a (potentially binary) string encoded using base64.
Base64String graphql.String

// Date is an ISO-8601 encoded date.
Date struct{ time.Time }

Expand Down Expand Up @@ -105,12 +105,12 @@ func (x *X509Certificate) UnmarshalJSON(data []byte) error {
return fmt.Errorf("X509Certificate.UnmarshalJSON: not implemented")
}

// NewBoolean is a helper to make a new *Boolean.
func NewBoolean(v Boolean) *Boolean { return &v }

// NewBase64String is a helper to make a new *Base64String.
func NewBase64String(v Base64String) *Base64String { return &v }

// NewBoolean is a helper to make a new *Boolean.
func NewBoolean(v Boolean) *Boolean { return &v }

// NewDate is a helper to make a new *Date.
func NewDate(v Date) *Date { return &v }

Expand Down
3 changes: 3 additions & 0 deletions scalar_test.go
Expand Up @@ -76,6 +76,9 @@ func equalError(a, b error) bool {
}

func TestNewScalars(t *testing.T) {
if got := githubv4.NewBase64String(""); got == nil {
t.Error("NewBase64String returned nil")
}
if got := githubv4.NewBoolean(false); got == nil {
t.Error("NewBoolean returned nil")
}
Expand Down

0 comments on commit 54eb371

Please sign in to comment.