-
Notifications
You must be signed in to change notification settings - Fork 106
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 #229 from nonrational/nip-io
Add support for nip.io with test coverage
- Loading branch information
Showing
4 changed files
with
55 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dev | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var testHttp HTTPServer | ||
|
||
func TestHttp_removeTLD_test(t *testing.T) { | ||
str := testHttp.removeTLD("psychic-octo-guide.test") | ||
|
||
assert.Equal(t, "psychic-octo-guide", str) | ||
} | ||
|
||
func TestHttp_removeTLD_noTld(t *testing.T) { | ||
str := testHttp.removeTLD("shiny-train") | ||
|
||
assert.Equal(t, "shiny-train", str) | ||
} | ||
|
||
func TestHttp_removeTLD_mutlipartDomain(t *testing.T) { | ||
str := testHttp.removeTLD("expert-eureka.loc.al") | ||
|
||
assert.Equal(t, "expert-eureka.loc", str) | ||
} | ||
|
||
func TestHttp_removeTLD_dev(t *testing.T) { | ||
str := testHttp.removeTLD("bookish-giggle.dev:8080") | ||
|
||
assert.Equal(t, "bookish-giggle", str) | ||
} | ||
|
||
func TestHttp_removeTLD_xipIoMalformed(t *testing.T) { | ||
str := testHttp.removeTLD("legendary-meme.0.0.xip.io") | ||
|
||
assert.Equal(t, "", str) | ||
} | ||
|
||
func TestHttp_removeTLD_xipIoDots(t *testing.T) { | ||
str := testHttp.removeTLD("legendary-meme.0.0.0.0.xip.io") | ||
|
||
assert.Equal(t, "legendary-meme", str) | ||
} | ||
|
||
func TestHttp_removeTLD_nipIoDots(t *testing.T) { | ||
str := testHttp.removeTLD("effective-invention.255.255.255.255.nip.io") | ||
|
||
assert.Equal(t, "effective-invention", str) | ||
} |
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