Skip to content

Commit

Permalink
remove useless tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antho1404 committed Jun 24, 2019
1 parent b11a3d5 commit 9284459
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 571 deletions.
120 changes: 0 additions & 120 deletions container/service_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,6 @@ import (
"github.com/stretchr/testify/require"
)

func startTestService(name []string) (string, error) {
c, err := New()
if err != nil {
return "", err
}
return c.StartService(ServiceOptions{
Image: "http-server",
Namespace: name,
})
}

func TestIntegrationStartService(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestStartService"}
serviceID, err := startTestService(namespace)
defer c.StopService(namespace)
require.NoError(t, err)
require.NotEqual(t, "", serviceID)
}

func TestIntegrationStartServiceTwice(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestStartServiceTwice"}
id1, err := startTestService(namespace)
require.NoError(t, err)
defer c.StopService(namespace)
id2, err := startTestService(namespace)
require.NoError(t, err)
require.Equal(t, id1, id2)
}

func TestIntegrationStopService(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestStopService"}
startTestService(namespace)
err = c.StopService(namespace)
require.NoError(t, err)
}

func TestIntegrationStopNotExistingService(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestStopNotExistingService"}
err = c.StopService(namespace)
require.NoError(t, err)
}

func TestIntegrationStatusNeverStarted(t *testing.T) {
c, err := New()
require.NoError(t, err)
Expand All @@ -68,72 +18,13 @@ func TestIntegrationStatusNeverStarted(t *testing.T) {
require.Equal(t, STOPPED, status)
}

func TestIntegrationStatusRunning(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestStatusRunning"}
startTestService(namespace)
defer c.StopService(namespace)
status, err := c.Status(namespace)
require.NoError(t, err)
require.Equal(t, status, RUNNING)
require.NotEqual(t, status, STOPPED)
}

func TestIntegrationStatusStopped(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestStatusStopped"}
startTestService(namespace)
c.StopService(namespace)
status, err := c.Status(namespace)
require.NoError(t, err)
require.Equal(t, status, STOPPED)
require.NotEqual(t, status, RUNNING)
}

func TestIntegrationFindServiceNotExisting(t *testing.T) {
c, err := New()
require.NoError(t, err)
_, err = c.FindService([]string{"TestFindServiceNotExisting"})
require.Error(t, err)
}

func TestIntegrationFindService(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestFindService"}
startTestService(namespace)
defer c.StopService(namespace)
service, err := c.FindService(namespace)
require.NoError(t, err)
require.NotEqual(t, "", service.ID)
}

func TestIntegrationFindServiceCloseName(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestFindServiceCloseName", "name"}
namespace1 := []string{"TestFindServiceCloseName", "name2"}
startTestService(namespace)
defer c.StopService(namespace)
startTestService(namespace1)
defer c.StopService(namespace1)
service, err := c.FindService(namespace)
require.NoError(t, err)
require.NotEqual(t, "", service.ID)
}

func TestIntegrationFindServiceStopped(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestFindServiceStopped"}
startTestService(namespace)
c.StopService(namespace)
_, err = c.FindService(namespace)
require.Error(t, err)
}

func TestIntegrationListServices(t *testing.T) {
c, err := New()
require.NoError(t, err)
Expand All @@ -158,14 +49,3 @@ func TestIntegrationListServices(t *testing.T) {
require.Equal(t, 1, len(services))
require.Equal(t, c.Namespace([]string{"TestListServices"}), services[0].Spec.Name)
}

func TestIntegrationServiceLogs(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestServiceLogs"}
startTestService(namespace)
defer c.StopService(namespace)
reader, err := c.ServiceLogs(namespace)
require.NoError(t, err)
require.NotNil(t, reader)
}
12 changes: 0 additions & 12 deletions container/task_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ import (
"github.com/stretchr/testify/require"
)

func TestIntegrationListTasks(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestListTasks"}
startTestService(namespace)
defer c.StopService(namespace)
tasks, err := c.ListTasks(namespace)
require.NoError(t, err)
require.NotNil(t, tasks)
require.Equal(t, 1, len(tasks))
}

func TestIntegrationTasksError(t *testing.T) {
c, err := New()
require.NoError(t, err)
Expand Down
21 changes: 0 additions & 21 deletions container/wait_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,6 @@ import (
"github.com/stretchr/testify/require"
)

func TestIntegrationWaitForStatusRunning(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestWaitForStatusRunning"}
startTestService(namespace)
defer c.StopService(namespace)
err = c.waitForStatus(namespace, RUNNING)
require.NoError(t, err)
}

func TestIntegrationWaitForStatusStopped(t *testing.T) {
c, err := New()
require.NoError(t, err)
namespace := []string{"TestWaitForStatusStopped"}
startTestService(namespace)
c.waitForStatus(namespace, RUNNING)
c.StopService(namespace)
err = c.waitForStatus(namespace, STOPPED)
require.NoError(t, err)
}

func TestIntegrationWaitForStatusTaskError(t *testing.T) {
c, err := New()
require.NoError(t, err)
Expand Down
55 changes: 0 additions & 55 deletions sdk/sdk_test.go

This file was deleted.

117 changes: 0 additions & 117 deletions server/grpc/core/core_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,126 +8,9 @@ import (

"github.com/mesg-foundation/core/config"
"github.com/mesg-foundation/core/protobuf/coreapi"
executionsdk "github.com/mesg-foundation/core/sdk/execution"
"github.com/mesg-foundation/core/service"
"github.com/stretchr/testify/require"
)

func TestExecute(t *testing.T) {
var (
taskKey = "call"
data = `{"url": "https://mesg.com", "data": {}, "headers": {}}`
server, closer = newServer(t)
)
defer closer()

s, validationErr, err := server.sdk.DeployService(serviceTar(t, taskServicePath), nil)
require.Zero(t, validationErr)
require.NoError(t, err)
defer server.sdk.DeleteService(s.Hash, false)

require.NoError(t, server.sdk.StartService(s.Hash))
defer server.sdk.StopService(s.Hash)

reply, err := server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash.String(),
TaskKey: taskKey,
InputData: data,
})
require.NoError(t, err)
require.NotEqual(t, "", reply.ExecutionHash)
}

func TestExecuteWithInvalidJSON(t *testing.T) {
server, closer := newServer(t)
defer closer()

s, validationErr, err := server.sdk.DeployService(serviceTar(t, taskServicePath), nil)
require.Zero(t, validationErr)
require.NoError(t, err)
defer server.sdk.DeleteService(s.Hash, false)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash.String(),
TaskKey: "test",
InputData: "",
})
require.Error(t, err)
require.Equal(t, err.Error(), "cannot parse execution's inputs (JSON format): unexpected end of JSON input")
}

func TestExecuteWithInvalidTask(t *testing.T) {
var (
taskKey = "error"
server, closer = newServer(t)
)
defer closer()

s, validationErr, err := server.sdk.DeployService(serviceTar(t, taskServicePath), nil)
require.Zero(t, validationErr)
require.NoError(t, err)
defer server.sdk.DeleteService(s.Hash, false)

require.NoError(t, server.sdk.StartService(s.Hash))
defer server.sdk.StopService(s.Hash)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash.String(),
TaskKey: taskKey,
InputData: "{}",
})
require.Error(t, err)
notFoundErr, ok := err.(*service.TaskNotFoundError)
require.True(t, ok)
require.Equal(t, taskKey, notFoundErr.TaskKey)
require.Equal(t, s.Name, notFoundErr.ServiceName)
}

func TestExecuteWithInvalidTaskInput(t *testing.T) {
var (
taskKey = "call"
data = `{"headers": {}}`
server, closer = newServer(t)
)
defer closer()

s, validationErr, err := server.sdk.DeployService(serviceTar(t, taskServicePath), nil)
require.Zero(t, validationErr)
require.NoError(t, err)
defer server.sdk.DeleteService(s.Hash, false)

require.NoError(t, server.sdk.StartService(s.Hash))
defer server.sdk.StopService(s.Hash)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash.String(),
TaskKey: taskKey,
InputData: data,
})
require.Error(t, err)
invalidErr, ok := err.(*service.InvalidTaskInputError)
require.True(t, ok)
require.Equal(t, taskKey, invalidErr.TaskKey)
require.Equal(t, s.Name, invalidErr.ServiceName)
}

func TestExecuteWithNonRunningService(t *testing.T) {
server, closer := newServer(t)
defer closer()

s, validationErr, err := server.sdk.DeployService(serviceTar(t, taskServicePath), nil)
require.Zero(t, validationErr)
require.NoError(t, err)
defer server.sdk.DeleteService(s.Hash, false)

_, err = server.ExecuteTask(context.Background(), &coreapi.ExecuteTaskRequest{
ServiceID: s.Hash.String(),
TaskKey: "test",
InputData: "{}",
})
require.Equal(t, &executionsdk.NotRunningServiceError{ServiceID: s.Hash.String()}, err)
}

func TestExecuteWithNonExistingService(t *testing.T) {
server, closer := newServer(t)
defer closer()
Expand Down
Loading

0 comments on commit 9284459

Please sign in to comment.