Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start listening on test server port before running tests. #491

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ const (
dbName = "test.db"
)

func server() {
func server(lis net.Listener) {
_ = os.Remove(dbName)
lis, err := net.Listen("tcp", port)
if err != nil {
logrus.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()

db, err := sql.Open("sqlite3", dbName)
Expand Down Expand Up @@ -66,7 +62,11 @@ func server() {
}

func TestMain(m *testing.M) {
go server()
lis, err := net.Listen("tcp", port)
if err != nil {
logrus.Fatalf("failed to listen: %v", err)
}
go server(lis)
exit := m.Run()
if err := os.Remove(dbName); err != nil {
logrus.Fatalf("couldn't remove db")
Expand Down Expand Up @@ -842,7 +842,6 @@ func TestListBundles(t *testing.T) {
"etcdoperator.v0.9.0",
}


var names []string
var gotBundles = make([]*api.Bundle, 0)

Expand Down