-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix empty Group Version Kind (#1044)
Signed-off-by: Jose Luis Vazquez Gonzalez <[email protected]>
- Loading branch information
josvaz
authored
Oct 28, 2022
1 parent
a95b663
commit f01bd4f
Showing
5 changed files
with
78 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package controller | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"testing" | ||
|
||
ssv1alpha1 "github.com/bitnami-labs/sealed-secrets/pkg/apis/sealedsecrets/v1alpha1" | ||
) | ||
|
||
func TestConvert2SealedSecretBadType(t *testing.T) { | ||
obj := struct{}{} | ||
_, got := convertSealedSecret(obj) | ||
want := ErrCast | ||
if !errors.Is(got, want) { | ||
t.Fatalf("got %v want %v", got, want) | ||
} | ||
} | ||
|
||
func TestConvert2SealedSecretFills(t *testing.T) { | ||
sealedSecret := ssv1alpha1.SealedSecret{} | ||
|
||
result, err := convertSealedSecret(any(&sealedSecret)) | ||
if err != nil { | ||
t.Fatalf("unexpected failure converting to a sealed secret: %v", err) | ||
} | ||
got := fmt.Sprintf("%s %s", result.APIVersion, result.Kind) | ||
want := "bitnami.com/v1alpha1 SealedSecret" | ||
if got != want { | ||
t.Fatalf("got %q want %q", got, want) | ||
} | ||
} | ||
|
||
func TestConvert2SealedSecretPassThrough(t *testing.T) { | ||
sealedSecret := ssv1alpha1.SealedSecret{} | ||
sealedSecret.APIVersion = "bitnami.com/v1alpha1" | ||
sealedSecret.Kind = "SealedSecrets" | ||
|
||
want := &sealedSecret | ||
got, err := convertSealedSecret(any(want)) | ||
if err != nil { | ||
t.Fatalf("unexpected failure converting to a sealed secret: %v", err) | ||
} | ||
if got != want { | ||
t.Fatalf("got %v want %v", got, want) | ||
} | ||
} |
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