-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from MysteriumNetwork/feature/MYST-27-broker-o…
…n-public-domain Feature/myst 27 broker on public domain
- Loading branch information
Showing
12 changed files
with
138 additions
and
42 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
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
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
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,85 @@ | ||
package nats_discovery | ||
|
||
import ( | ||
"encoding/json" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestContactSerialize(t *testing.T) { | ||
var tests = []struct { | ||
model ContactNATSV1 | ||
expectedJson string | ||
}{ | ||
{ | ||
ContactNATSV1{ | ||
Topic: "topic1234", | ||
BrokerAddresses: []string{"nats://far-server:4222"}, | ||
}, | ||
`{ | ||
"topic": "topic1234", | ||
"broker_addresses":["nats://far-server:4222"] | ||
}`, | ||
}, | ||
{ | ||
ContactNATSV1{ | ||
Topic: "topic1234", | ||
BrokerAddresses: []string{"nats://far-server1:4222", "nats://far-server2:4222"}, | ||
}, | ||
`{ | ||
"topic": "topic1234", | ||
"broker_addresses":["nats://far-server1:4222", "nats://far-server2:4222"] | ||
}`, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
jsonBytes, err := json.Marshal(test.model) | ||
|
||
assert.Nil(t, err) | ||
assert.JSONEq(t, test.expectedJson, string(jsonBytes)) | ||
} | ||
} | ||
|
||
func TestLocationUnserialize(t *testing.T) { | ||
var tests = []struct { | ||
json string | ||
expectedModel ContactNATSV1 | ||
expectedError error | ||
}{ | ||
{ | ||
`{ | ||
"topic": "topic1234", | ||
"broker_addresses":["nats://far-server1:4222"] | ||
}`, | ||
ContactNATSV1{ | ||
Topic: "topic1234", | ||
BrokerAddresses: []string{"nats://far-server1:4222"}, | ||
}, | ||
nil, | ||
}, | ||
{ | ||
`{ | ||
"topic": "topic1234", | ||
"broker_addresses":["nats://far-server1:4222", "nats://far-server2:4222"] | ||
}`, | ||
ContactNATSV1{ | ||
Topic: "topic1234", | ||
BrokerAddresses: []string{"nats://far-server1:4222", "nats://far-server2:4222"}, | ||
}, | ||
nil, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
var model ContactNATSV1 | ||
err := json.Unmarshal([]byte(test.json), &model) | ||
|
||
assert.Equal(t, test.expectedModel, model) | ||
if test.expectedError != nil { | ||
assert.EqualError(t, err, test.expectedError.Error()) | ||
} else { | ||
assert.NoError(t, 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