frankgh commented on code in PR #312:
URL: https://github.com/apache/cassandra-sidecar/pull/312#discussion_r2761281555
##########
server/src/test/java/org/apache/cassandra/sidecar/cluster/instance/InstanceMetadataImplTest.java:
##########
@@ -200,6 +200,56 @@ void testResolvesDefaultDirectories()
assertThat(metadata.savedCachesDir()).isEqualTo(rootDir +
"/saved_caches");
}
+ @Test
+ void testDefaultStoragePort()
+ {
+ String rootDir = tempDir.toString();
+ InstanceMetadata metadata = InstanceMetadataImpl.builder()
+ .id(ID)
+ .host(HOST)
+ .port(PORT)
+
.metricRegistry(METRIC_REGISTRY)
+ .storageDir(rootDir)
+ .build();
+ assertThat(metadata.storagePort()).isEqualTo(7000);
+ }
+
+ @Test
+ void testCustomStoragePort()
+ {
+ String rootDir = tempDir.toString();
+ for (int customStoragePort : new int[]{ 1, 65535, 7005 })
+ {
+ InstanceMetadata metadata = InstanceMetadataImpl.builder()
+ .id(ID)
+ .host(HOST)
+ .port(PORT)
+
.storagePort(customStoragePort)
+
.metricRegistry(METRIC_REGISTRY)
+
.storageDir(rootDir)
+ .build();
+ assertThat(metadata.storagePort()).isEqualTo(customStoragePort);
+ }
+ }
+
+ @Test
+ void testInvalidStoragePort()
Review Comment:
NIT: prefer parameterized test
```suggestion
@ParameterizedTest(name = "{index} => invalid storagePort={0}")
@ValueSource(ints = { 0, -1, 65536 })
```
##########
server/src/test/java/org/apache/cassandra/sidecar/cluster/instance/InstanceMetadataImplTest.java:
##########
@@ -200,6 +200,56 @@ void testResolvesDefaultDirectories()
assertThat(metadata.savedCachesDir()).isEqualTo(rootDir +
"/saved_caches");
}
+ @Test
+ void testDefaultStoragePort()
+ {
+ String rootDir = tempDir.toString();
+ InstanceMetadata metadata = InstanceMetadataImpl.builder()
+ .id(ID)
+ .host(HOST)
+ .port(PORT)
+
.metricRegistry(METRIC_REGISTRY)
+ .storageDir(rootDir)
+ .build();
+ assertThat(metadata.storagePort()).isEqualTo(7000);
+ }
+
+ @Test
+ void testCustomStoragePort()
Review Comment:
NIT: prefer parameterized test
```suggestion
@ParameterizedTest(name = "{index} => storagePort={0}")
@ValueSource(ints = { 1, 65535, 7005 })
void testCustomStoragePort(int customStoragePort)
```
##########
server/src/test/java/org/apache/cassandra/sidecar/cluster/instance/InstanceMetadataImplTest.java:
##########
@@ -200,6 +200,56 @@ void testResolvesDefaultDirectories()
assertThat(metadata.savedCachesDir()).isEqualTo(rootDir +
"/saved_caches");
}
+ @Test
+ void testDefaultStoragePort()
+ {
+ String rootDir = tempDir.toString();
+ InstanceMetadata metadata = InstanceMetadataImpl.builder()
+ .id(ID)
+ .host(HOST)
+ .port(PORT)
+
.metricRegistry(METRIC_REGISTRY)
+ .storageDir(rootDir)
+ .build();
+ assertThat(metadata.storagePort()).isEqualTo(7000);
+ }
+
+ @Test
+ void testCustomStoragePort()
+ {
+ String rootDir = tempDir.toString();
+ for (int customStoragePort : new int[]{ 1, 65535, 7005 })
+ {
Review Comment:
Not needed when using a parameterized test
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]