-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b09b779
commit a27d553
Showing
1 changed file
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,44 @@ | ||
package limits | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/api/resource" | ||
) | ||
|
||
func TestName(t *testing.T) { | ||
c := Config{} | ||
if c.Name() != "limits" { | ||
t.Fatal("Failed name test") | ||
} | ||
} | ||
|
||
func TestQtyHook(t *testing.T) { | ||
var i int | ||
test := "1G" | ||
vtype := reflect.TypeOf(i) | ||
v, err := QtyHookFunc(vtype, vtype, test) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if v.(string) != test { | ||
t.Fatal("Expecting skip on not being string") | ||
} | ||
stype := reflect.TypeOf(test) | ||
v, err = QtyHookFunc(stype, vtype, test) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if v.(string) != test { | ||
t.Fatal("Expecting skip on not being qty") | ||
} | ||
vtype = reflect.TypeOf(resource.Quantity{}) | ||
v, err = QtyHookFunc(stype, vtype, test) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if reflect.TypeOf(resource.Quantity{}) != reflect.TypeOf(v) { | ||
t.Fatal("Expecting return of qty") | ||
} | ||
} |