Skip to content

Commit

Permalink
final pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
toppercodes committed Jul 9, 2024
1 parent c4a281d commit b9b65cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
14 changes: 9 additions & 5 deletions axiom/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ import (
"go.opentelemetry.io/otel/trace"
)

//go:generate go run golang.org/x/tools/cmd/stringer -type=Action -linecomment -output=action_string.go
//go:generate go run golang.org/x/tools/cmd/stringer -type=Action -linecomment -output=tokens_string.go

// Action represents an action that can be performed on an Axiom resource.
type Action uint8

// All available [Action].
const (
ActionCreate Action = iota // create
ActionRead // read
ActionUpdate // update
ActionDelete // delete
emptyAction Action = iota //

ActionCreate // create
ActionRead // read
ActionUpdate // update
ActionDelete // delete
)

func actionFromString(s string) (a Action) {
switch s {
case emptyAction.String():
a = emptyAction
case ActionCreate.String():
a = ActionCreate
case ActionRead.String():
Expand Down
8 changes: 0 additions & 8 deletions axiom/tokens_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ func TestTokensTestSuite(t *testing.T) {
suite.Run(t, new(TokensTestSuite))
}

func (s *TokensTestSuite) SetupSuite() {
s.IntegrationTestSuite.SetupSuite()
}

func (s *TokensTestSuite) TearDownSuite() {
s.IntegrationTestSuite.TearDownSuite()
}

func (s *TokensTestSuite) SetupTest() {
s.IntegrationTestSuite.SetupTest()

Expand Down
13 changes: 7 additions & 6 deletions axiom/action_string.go → axiom/tokens_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions axiom/tokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,10 @@ func TestTokensService_Delete(t *testing.T) {
err := client.Tokens.Delete(context.Background(), "testID")
require.NoError(t, err)
}

func TestActionFromStringString(t *testing.T) {
for p := ActionCreate; p <= ActionDelete; p++ {
parsed := actionFromString(p.String())
assert.Equal(t, p, parsed)
}
}

0 comments on commit b9b65cb

Please sign in to comment.