Skip to content

Commit

Permalink
test: game options
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-sirotin committed Jun 2, 2024
1 parent 5438dbc commit 02a54a1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkg/game/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package game

import (
mock_transport "2sp/internal/transport/mock"
mock_storage "2sp/pkg/storage/mock"
"context"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"testing"
)

func TestOptions(t *testing.T) {
ctx := context.Background()
transport := &mock_transport.MockService{}
storage := &mock_storage.MockService{}
logger := zap.NewNop()
const enableSymmetricEncryption = false

options := []Option{
WithContext(ctx),
WithTransport(transport),
WithStorage(storage),
WithLogger(logger),
WithEnableSymmetricEncryption(false),
}
game := NewGame(options)

require.NotNil(t, game)
require.Equal(t, ctx, game.ctx)
require.Equal(t, transport, game.transport)
require.Equal(t, storage, game.storage)
require.Equal(t, logger, game.logger)
require.Equal(t, enableSymmetricEncryption, game.config.EnableSymmetricEncryption)
}

func TestNoTransport(t *testing.T) {
options := []Option{
WithTransport(nil),
}
game := NewGame(options)
require.Nil(t, game)
}
2 changes: 2 additions & 0 deletions pkg/storage/service.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package storage

//go:generate mockgen -source=service.go -destination=mock/service.go

import (
"2sp/pkg/protocol"
)
Expand Down

0 comments on commit 02a54a1

Please sign in to comment.