-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We don't want the equality testing as is done here, but some sort of "kinda looks like" testing to make sure we don't add magic providers when a provider has been explicitly configured. So rename the method and loosen the comparisons.
- Loading branch information
Showing
13 changed files
with
53 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package herd | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestDuplicateProviders(t *testing.T) { | ||
r := NewRegistry("/nonexistent", "/nonexistent") | ||
p := NewConsulProvider("test") | ||
p.(*ConsulProvider).Address = "http://consul:8080" | ||
r.AddProvider(p) | ||
os.Setenv("CONSUL_HTTP_ADDR", "http://consul:8080") | ||
r.AddMagicProvider(NewCacheFromProvider(NewConsulProvider("test 2"))) | ||
if len(r.providers) != 1 { | ||
t.Errorf("AddMagicProviders did not detect duplicate consul provider") | ||
} | ||
os.Setenv("CONSUL_HTTP_ADDR", "http://consul:8081") | ||
r.AddMagicProvider(NewCacheFromProvider(NewConsulProvider("test 3"))) | ||
if len(r.providers) != 2 { | ||
t.Errorf("AddMagicProviders detected a duplicate provider where there is none") | ||
} | ||
} |
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