Skip to content

Commit

Permalink
fix: lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Zygimantass committed Jan 15, 2025
1 parent 60bcb49 commit 3f1f100
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
31 changes: 25 additions & 6 deletions core/provider/docker/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func setupTest(tb testing.TB, name string) func(testing.TB, string) {

if len(nets) != 0 {
for _, net := range nets {
client.NetworkRemove(context.Background(), net.ID)
err := client.NetworkRemove(context.Background(), net.ID)
require.NoError(tb, err)
}
}
}
Expand All @@ -46,7 +47,9 @@ func TestCreateProviderDuplicateNetwork(t *testing.T) {

p1, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p1.Teardown(ctx)
defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p1)

p2, err := docker.CreateProvider(ctx, logger, providerName)
require.Error(t, err)
Expand All @@ -63,7 +66,9 @@ func TestCreateProvider(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)
defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

state := p.GetState()
assert.Equal(t, providerName, state.Name)
Expand Down Expand Up @@ -97,9 +102,14 @@ func TestRestoreProvider(t *testing.T) {
func TestCreateTask(t *testing.T) {
logger, _ := zap.NewDevelopment()
providerName := gonanoid.MustGenerate(idAlphabet, 10)
ctx := context.Background()

p, err := docker.CreateProvider(context.Background(), logger, providerName)
require.NoError(t, err)
defer p.Teardown(context.Background())

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

tests := []struct {
name string
Expand Down Expand Up @@ -169,9 +179,13 @@ func TestConcurrentTaskCreation(t *testing.T) {

logger, _ := zap.NewDevelopment()
providerName := gonanoid.MustGenerate(idAlphabet, 10)

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

numTasks := 10
var wg sync.WaitGroup
Expand Down Expand Up @@ -232,9 +246,13 @@ func TestProviderSerialization(t *testing.T) {
logger, _ := zap.NewDevelopment()

providerName := gonanoid.MustGenerate(idAlphabet, 10)

p1, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p1.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p1)

_, err = p1.CreateTask(ctx, provider.TaskDefinition{
Name: fmt.Sprintf("%s-test-task", providerName),
Expand Down Expand Up @@ -296,6 +314,7 @@ func TestRestoreTask(t *testing.T) {
Image: provider.ImageDefinition{Image: "busybox:latest", GID: "1000", UID: "1000"},
DataDir: "/data",
})
require.NoError(t, err)

dockerTask := task.(*docker.Task)

Expand Down
6 changes: 3 additions & 3 deletions core/provider/docker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func (t *Task) Destroy(ctx context.Context) error {
return nil
}

func (t *Task) ensure(_ context.Context) error {
return nil
}
//func (t *Task) ensure(_ context.Context) error {
// return nil
//}

func (t *Task) GetExternalAddress(ctx context.Context, port string) (string, error) {
t.provider.logger.Debug("getting external address", zap.String("id", t.state.Id))
Expand Down
25 changes: 20 additions & 5 deletions core/provider/docker/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ func TestTaskLifecycle(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

task, err := p.CreateTask(ctx, provider.TaskDefinition{
Name: "test",
Expand Down Expand Up @@ -73,7 +76,10 @@ func TestTaskExposingPort(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

task, err := p.CreateTask(ctx, provider.TaskDefinition{
Name: "test",
Expand Down Expand Up @@ -118,7 +124,10 @@ func TestTaskRunCommand(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

task, err := p.CreateTask(ctx, provider.TaskDefinition{
Name: "test",
Expand Down Expand Up @@ -166,7 +175,10 @@ func TestTaskRunCommandWhileStopped(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

task, err := p.CreateTask(ctx, provider.TaskDefinition{
Name: "test",
Expand Down Expand Up @@ -211,7 +223,10 @@ func TestTaskReadWriteFile(t *testing.T) {

p, err := docker.CreateProvider(ctx, logger, providerName)
require.NoError(t, err)
defer p.Teardown(ctx)

defer func(ctx context.Context, p provider.ProviderI) {
require.NoError(t, p.Teardown(ctx))
}(ctx, p)

task, err := p.CreateTask(ctx, provider.TaskDefinition{
Name: "test",
Expand Down

0 comments on commit 3f1f100

Please sign in to comment.