Last active
March 29, 2019 08:23
-
-
Save milosgajdos/4d3e6bd6ed62744ea27e to your computer and use it in GitHub Desktop.
NATS test
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
package queue_test | |
import ( | |
"os" | |
"testing" | |
"github.com/nats-io/gnatsd/server" | |
"github.com/nats-io/gnatsd/test" | |
"github.com/nats-io/nats" | |
) | |
var TestOptions = server.Options{ | |
Host: "localhost", | |
Port: 4222, | |
NoLog: true, | |
NoSigs: true, | |
} | |
func TestMain(m *testing.M) { | |
gnatsd := test.RunServer(&TestOptions) | |
defer gnatsd.Shutdown() | |
if gnatsd != nil { | |
options := nats.DefaultOptions | |
conn, err := (&options).Connect() | |
if err != nil { | |
panic(err) | |
} | |
conn.Close() | |
} else { | |
panic("Could not start GNATS queue server") | |
} | |
ret := m.Run() | |
os.Exit(ret) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this..