-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put back tests that were deleted because they use a remote url to dep…
…loy a service
- Loading branch information
1 parent
0b54217
commit 70e82f0
Showing
7 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// +build integration | ||
|
||
package core | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mesg-foundation/core/api" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIntegrationDeployService(t *testing.T) { | ||
url := "git://github.com/mesg-foundation/service-webhook#single-outputs" | ||
|
||
server, closer := newServer(t) | ||
defer closer() | ||
stream := newTestDeployStream(url) | ||
|
||
require.Nil(t, server.DeployService(stream)) | ||
defer server.api.DeleteService(stream.hash, false) | ||
|
||
require.Len(t, stream.sid, 7) | ||
require.NotEmpty(t, stream.hash) | ||
require.Contains(t, stream.statuses, api.DeployStatus{ | ||
Message: "Image built with success", | ||
Type: api.DonePositive, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package core | ||
|
||
import ( | ||
"io/ioutil" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/mesg-foundation/core/api" | ||
"github.com/mesg-foundation/core/protobuf/coreapi" | ||
"github.com/stretchr/testify/require" | ||
grpc "google.golang.org/grpc" | ||
) | ||
|
||
func TestDeployService(t *testing.T) { | ||
url := "git://github.com/mesg-foundation/service-webhook#single-outputs" | ||
|
||
server, dt, closer := newServerAndDockerTest(t) | ||
defer closer() | ||
dt.ProvideImageBuild(ioutil.NopCloser(strings.NewReader(`{"stream":"sha256:x"}`)), nil) | ||
|
||
stream := newTestDeployStream(url) | ||
require.Nil(t, server.DeployService(stream)) | ||
require.Len(t, stream.sid, 7) | ||
require.NotEmpty(t, stream.hash) | ||
|
||
require.Contains(t, stream.statuses, api.DeployStatus{ | ||
Message: "Image built with success", | ||
Type: api.DonePositive, | ||
}) | ||
} | ||
|
||
// TODO(ilgooz) also add tests for receiving chunks. | ||
type testDeployStream struct { | ||
url string // Git repo url. | ||
err error | ||
sid string | ||
hash string | ||
statuses []api.DeployStatus | ||
grpc.ServerStream | ||
} | ||
|
||
func newTestDeployStream(url string) *testDeployStream { | ||
return &testDeployStream{url: url} | ||
} | ||
|
||
func (s *testDeployStream) Send(m *coreapi.DeployServiceReply) error { | ||
s.sid = m.GetService().GetSid() | ||
s.hash = m.GetService().GetHash() | ||
|
||
status := m.GetStatus() | ||
if status != nil { | ||
var typ api.StatusType | ||
switch status.Type { | ||
case coreapi.DeployServiceReply_Status_RUNNING: | ||
typ = api.Running | ||
case coreapi.DeployServiceReply_Status_DONE_POSITIVE: | ||
typ = api.DonePositive | ||
case coreapi.DeployServiceReply_Status_DONE_NEGATIVE: | ||
typ = api.DoneNegative | ||
} | ||
s.statuses = append(s.statuses, api.DeployStatus{ | ||
Message: status.Message, | ||
Type: typ, | ||
}) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (s *testDeployStream) Recv() (*coreapi.DeployServiceRequest, error) { | ||
return &coreapi.DeployServiceRequest{ | ||
Value: &coreapi.DeployServiceRequest_Url{Url: s.url}, | ||
}, s.err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters