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

Some unit tests in connection were showing a race condition (see #31): #56

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestDefaultClientProperties(t *testing.T) {

go func() {
srv.connectionOpen()
rwc.Close()

}()

if c, err := Open(rwc, defaultConfig()); err != nil {
Expand All @@ -229,13 +229,14 @@ func TestDefaultClientProperties(t *testing.T) {
t.Errorf("expected product %s got: %s", want, got)
}

if want, got := defaultVersion, srv.start.ClientProperties["version"]; want != got {
if want, got := buildVersion, srv.start.ClientProperties["version"]; want != got {
t.Errorf("expected version %s got: %s", want, got)
}

if want, got := defaultLocale, srv.start.Locale; want != got {
t.Errorf("expected locale %s got: %s", want, got)
}
rwc.Close()
}

func TestCustomClientProperties(t *testing.T) {
Expand All @@ -249,7 +250,7 @@ func TestCustomClientProperties(t *testing.T) {

go func() {
srv.connectionOpen()
rwc.Close()

}()

if c, err := Open(rwc, config); err != nil {
Expand All @@ -263,18 +264,21 @@ func TestCustomClientProperties(t *testing.T) {
if want, got := config.Properties["version"], srv.start.ClientProperties["version"]; want != got {
t.Errorf("expected version %s got: %s", want, got)
}

rwc.Close()
}

func TestOpen(t *testing.T) {
rwc, srv := newSession(t)
go func() {
srv.connectionOpen()
rwc.Close()

}()

if c, err := Open(rwc, defaultConfig()); err != nil {
t.Fatalf("could not create connection: %v (%s)", c, err)
}
rwc.Close()
}

func TestChannelOpen(t *testing.T) {
Expand Down Expand Up @@ -326,7 +330,7 @@ func TestOpenAMQPlainAuth(t *testing.T) {

srv.recv(0, &connectionOpen{})
srv.send(0, &connectionOpenOk{})
rwc.Close()

auth <- table
}()

Expand All @@ -340,6 +344,7 @@ func TestOpenAMQPlainAuth(t *testing.T) {
if table["PASSWORD"] != defaultPassword {
t.Fatalf("unexpected password: want: %s, got: %s", defaultPassword, table["PASSWORD"])
}
rwc.Close()
}

func TestOpenFailedCredentials(t *testing.T) {
Expand Down