Skip to content

Commit cd4fb63

Browse files
committed
Add VersionHelper unit tests
1 parent bfd3ed3 commit cd4fb63

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2018, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
4+
package oracle.kubernetes.operator.helpers;
5+
6+
import io.kubernetes.client.models.V1ObjectMeta;
7+
import static oracle.kubernetes.operator.LabelConstants.*;
8+
import static oracle.kubernetes.operator.create.KubernetesArtifactUtils.*;
9+
import static oracle.kubernetes.operator.helpers.VersionHelper.*;
10+
import static org.hamcrest.MatcherAssert.*;
11+
import static org.hamcrest.Matchers.*;
12+
import org.junit.Test;
13+
14+
public class VersionHelperTest {
15+
16+
private static final String V1 = "v1";
17+
18+
@Test
19+
public void null_metadata_returns_false() throws Exception {
20+
assertThat(matchesResourceVersion(null, V1), equalTo(false));
21+
}
22+
23+
@Test
24+
public void null_labels_returns_false() throws Exception {
25+
assertThat(matchesResourceVersion(newObjectMeta().labels(null), V1), equalTo(false));
26+
}
27+
28+
@Test
29+
public void null_version_returns_false() throws Exception {
30+
assertThat(matchesResourceVersion(newObjectMeta().putLabelsItem(RESOURCE_VERSION_LABEL, null), V1), equalTo(false));
31+
}
32+
33+
@Test
34+
public void different_version_returns_false() throws Exception {
35+
assertThat(matchesResourceVersion(newObjectMeta().putLabelsItem(RESOURCE_VERSION_LABEL, "v2"), V1), equalTo(false));
36+
}
37+
38+
@Test
39+
public void same_version_returns_true() throws Exception {
40+
assertThat(matchesResourceVersion(newObjectMeta().putLabelsItem(RESOURCE_VERSION_LABEL, V1), V1), equalTo(true));
41+
}
42+
}

0 commit comments

Comments
 (0)