generated from kedacore/github-template
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Convert deprecate host field to hosts field
Signed-off-by: Jocelyn Thode <jocelyn@thode.email>
- Loading branch information
1 parent
d1c519e
commit aadba5a
Showing
8 changed files
with
238 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package http | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSanitizeHostsWithOnlyHosts(t *testing.T) { | ||
r := require.New(t) | ||
|
||
testInfra := newCommonTestInfra("testns", "testapp") | ||
spec := testInfra.httpso.Spec | ||
|
||
r.NoError(sanitizeHosts( | ||
testInfra.logger, | ||
&testInfra.httpso, | ||
)) | ||
|
||
r.Equal(spec.Hosts, testInfra.httpso.Spec.Hosts) | ||
r.Nil(testInfra.httpso.Spec.Host) | ||
} | ||
|
||
func TestSanitizeHostsWithBothHostAndHosts(t *testing.T) { | ||
r := require.New(t) | ||
|
||
testInfra := newBrokenTestInfra("testns", "testapp") | ||
|
||
err := sanitizeHosts( | ||
testInfra.logger, | ||
&testInfra.httpso, | ||
) | ||
r.Error(err) | ||
} | ||
|
||
func TestSanitizeHostsWithOnlyHost(t *testing.T) { | ||
r := require.New(t) | ||
|
||
testInfra := newDeprecatedTestInfra("testns", "testapp") | ||
spec := testInfra.httpso.Spec | ||
|
||
r.NoError(sanitizeHosts( | ||
testInfra.logger, | ||
&testInfra.httpso, | ||
)) | ||
|
||
r.NotEqual(spec.Hosts, testInfra.httpso.Spec.Hosts) | ||
r.NotEqual(spec.Host, testInfra.httpso.Spec.Host) | ||
r.Nil(testInfra.httpso.Spec.Host) | ||
r.Equal([]string{*spec.Host}, testInfra.httpso.Spec.Hosts) | ||
} | ||
|
||
func TestSanitizeHostsWithNoHostOrHosts(t *testing.T) { | ||
r := require.New(t) | ||
|
||
testInfra := newEmptyHostTestInfra("testns", "testapp") | ||
|
||
err := sanitizeHosts( | ||
testInfra.logger, | ||
&testInfra.httpso, | ||
) | ||
r.Error(err) | ||
r.Nil(testInfra.httpso.Spec.Host) | ||
r.Nil(testInfra.httpso.Spec.Hosts) | ||
} |
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