-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
option to query metric only on polling interval
Signed-off-by: Zbynek Roubalik <[email protected]>
- Loading branch information
Showing
87 changed files
with
1,050 additions
and
1,166 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,81 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type testData struct { | ||
description string | ||
expectedIdentifier string | ||
name string | ||
namespace string | ||
kind string | ||
} | ||
|
||
var tests = []testData{ | ||
{ | ||
description: "all lowercase", | ||
expectedIdentifier: "scaledobject.namespace.name", | ||
name: "name", | ||
namespace: "namespace", | ||
kind: "scaledobject", | ||
}, | ||
{ | ||
description: "all uppercase", | ||
expectedIdentifier: "scaledobject.namespace.name", | ||
name: "NAME", | ||
namespace: "NAMESPACE", | ||
kind: "SCALEDOBJECT", | ||
}, | ||
{ | ||
description: "camel case", | ||
expectedIdentifier: "scaledobject.namespace.name", | ||
name: "name", | ||
namespace: "namespace", | ||
kind: "scaledobject", | ||
}, | ||
{ | ||
description: "missing namespace", | ||
expectedIdentifier: "scaledobject..name", | ||
name: "name", | ||
kind: "scaledobject", | ||
}, | ||
} | ||
|
||
func TestGeneratedIdentifierForScaledObject(t *testing.T) { | ||
for _, test := range tests { | ||
test := test | ||
t.Run(test.name, func(t *testing.T) { | ||
expectedIdentifier := test.expectedIdentifier | ||
genericIdentifier := GenerateIdentifier(test.kind, test.namespace, test.name) | ||
|
||
scaledObject := &ScaledObject{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: test.name, | ||
Namespace: test.namespace, | ||
}, | ||
} | ||
scaledObjectIdentifier := scaledObject.GenerateIdentifier() | ||
|
||
withTriggers, err := AsDuckWithTriggers(scaledObject) | ||
if err != nil { | ||
t.Errorf("got error while converting to WithTriggers object: %s", err) | ||
} | ||
withTriggersIdentifier := withTriggers.GenerateIdentifier() | ||
|
||
if expectedIdentifier != genericIdentifier { | ||
t.Errorf("genericIdentifier=%q doesn't equal the expectedIdentifier=%q", genericIdentifier, expectedIdentifier) | ||
} | ||
|
||
if expectedIdentifier != scaledObjectIdentifier { | ||
t.Errorf("scaledObjectIdentifier=%q doesn't equal the expectedIdentifier=%q", scaledObjectIdentifier, expectedIdentifier) | ||
} | ||
|
||
if expectedIdentifier != withTriggersIdentifier { | ||
t.Errorf("withTriggersIdentifier=%q doesn't equal the expectedIdentifier=%q", withTriggersIdentifier, expectedIdentifier) | ||
} | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.