Skip to content

Commit 68f0298

Browse files
committed
fix some tests
1 parent 1a3878e commit 68f0298

File tree

34 files changed

+28
-376
lines changed

34 files changed

+28
-376
lines changed

src/main/java/com/dtsx/astra/cli/commands/db/cqlsh/CqlshExecCmd.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public static class RawExecSource {
3838
@Option(
3939
names = { "-e", "--execute" },
4040
description = "Execute the statement then exit",
41+
fallbackValue = "-",
42+
arity = "0..1",
4143
paramLabel = "STATEMENT"
4244
)
4345
public Optional<String> $statement = Optional.empty();

src/test/java/com/dtsx/astra/cli/integration/core/CliPropertiesImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void dsbulk(SystemProperties systemProps) {
5555
val dsbulk = cliProps.dsbulk();
5656

5757
assertThat(dsbulk.url()).isEqualTo("<dsbulk_url>");
58-
assertThat(dsbulk.version()).isEqualTo("6.5.4");
58+
assertThat(dsbulk.version()).isEqualTo("v6.5.4");
5959
}
6060

6161
@Test

src/test/java/com/dtsx/astra/cli/snapshot/commands/db/cqlsh/CqlshExecCmdSnapshotTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,34 @@ public class CqlshExecCmdSnapshotTest extends BaseCqlshExecCmd {
2121

2222
@TestForDifferentOutputs
2323
public void error_db_not_found(OutputType outputType) {
24-
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "CONSISTENCY"), outputType, dbNotFoundOpts);
24+
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-e", "CONSISTENCY"), outputType, dbNotFoundOpts);
2525
}
2626

2727
@TestForAllOutputs
2828
public void exec_string_success(OutputType outputType) {
29-
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "CONSISTENCY"), outputType, dbFoundOpts.andThen(disclaimerComments));
29+
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-e", "CONSISTENCY"), outputType, dbFoundOpts.andThen(disclaimerComments));
3030
}
3131

3232
@TestForAllOutputs
3333
public void exec_string_fail(OutputType outputType) {
34-
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "DESC CARS"), outputType, dbFoundOpts.andThen(disclaimerComments));
34+
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-e", "DESC CARS"), outputType, dbFoundOpts.andThen(disclaimerComments));
3535
}
3636

3737
@TestForAllOutputs
3838
public void exec_string_stdin_implied(OutputType outputType) {
39-
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}"), outputType, o -> o.use(dbFoundOpts).use(disclaimerComments)
39+
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-e"), outputType, o -> o.use(dbFoundOpts).use(disclaimerComments)
4040
.stdin("CONSISTENCY;"));
4141
}
4242

4343
@TestForAllOutputs
4444
public void exec_string_stdin_explicit(OutputType outputType) {
45-
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-"), outputType, o -> o.use(dbFoundOpts).use(disclaimerComments)
45+
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-e", "-"), outputType, o -> o.use(dbFoundOpts).use(disclaimerComments)
4646
.stdin("CONSISTENCY;"));
4747
}
4848

4949
@TestForDifferentOutputs
5050
public void exec_string_stdin_multiline(OutputType outputType) {
51-
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}"), outputType, o -> o.use(dbFoundOpts).use(disclaimerComments)
51+
verifyRun(escape("db", "cqlsh", "exec", "${DatabaseName}", "-e"), outputType, o -> o.use(dbFoundOpts).use(disclaimerComments)
5252
.stdin("CONSISTENCY;\\\nSHOW VERSION;\\\nHELP"));
5353
}
5454
}

src/test/java/com/dtsx/astra/cli/unit/operations/UpgradeOperationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Optional;
2424

2525
import static org.assertj.core.api.Assertions.assertThatThrownBy;
26+
import static org.mockito.ArgumentMatchers.any;
2627
import static org.mockito.Mockito.mock;
2728
import static org.mockito.Mockito.when;
2829

@@ -147,6 +148,7 @@ public void throws_when_managed_by_package_manager() throws Exception {
147148
.isEqualTo(ExitCode.UNSUPPORTED_EXECUTION);
148149
}
149150

151+
@SuppressWarnings("SameParameterValue")
150152
private CliContext mkCtx(String version, SupportedPackageManager pm) throws Exception {
151153
val binaryPath = testCtx.get().path("/usr/local/bin/astra");
152154
Files.createDirectories(binaryPath.getParent());
@@ -156,7 +158,7 @@ private CliContext mkCtx(String version, SupportedPackageManager pm) throws Exce
156158
val mockProperties = mock(CliProperties.class);
157159

158160
when(mockProperties.version()).thenReturn(Version.mkUnsafe(version));
159-
when(mockProperties.cliPath(originalCtx)).thenReturn(new AstraBinary(binaryPath));
161+
when(mockProperties.cliPath(any())).thenReturn(new AstraBinary(binaryPath));
160162
when(mockProperties.owningPackageManager()).thenReturn(Optional.ofNullable(pm));
161163

162164
return originalCtx.withProperties(mockProperties);

src/test/resources/snapshots/_db/_cqlsh/CqlshExecCmd/error_db_not_found.human.approved.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
---- meta ----
2-
command: astra db cqlsh exec two_regions_db CONSISTENCY
2+
command: astra db cqlsh exec two_regions_db -e CONSISTENCY
33
exit_code: 2
44
---- output ----
5-
stderr: [WARNING] Providing the CQL statement as a positional parameter is deprecated and will be removed in future versions.
6-
stderr: [WARNING] Please use the 'astra db cqlsh exec -e "CQL STATEMENT"' syntax instead.
75
stderr: Error: A database named 'two_regions_db' could not be found.
86
stderr:
97
stderr: Please ensure that:

src/test/resources/snapshots/_db/_cqlsh/CqlshExecCmd/error_db_not_found.json.approved.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
---- meta ----
2-
command: astra db cqlsh exec two_regions_db CONSISTENCY -o json
2+
command: astra db cqlsh exec two_regions_db -e CONSISTENCY -o json
33
exit_code: 2
44
---- output ----
5-
stderr: [WARNING] Providing the CQL statement as a positional parameter is deprecated and will be removed in future versions.
6-
stderr: [WARNING] Please use the 'astra db cqlsh exec -e "CQL STATEMENT"' syntax instead.
75
stdout: {
86
stdout: "code" : "DATABASE_NOT_FOUND",
97
stdout: "message" : "Error: A database named 'two_regions_db' could not be found.\n\nPlease ensure that:\n - You are using the correct token/organization.\n - You are using the correct database name.",
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
---- meta ----
2-
command: astra db cqlsh exec two_regions_db 'DESC CARS' -o csv
2+
command: astra db cqlsh exec two_regions_db -e 'DESC CARS' -o csv
33
exit_code: 0
44
comments:
55
| Can't really test human output since we don't capture cqlsh output for human outputs
66
| But at least we can verify the command runs and the exit code is correct
77
| (human output returns cqlsh exit code; non-human output returns the cqlsh exit code via a field)
88
---- output ----
9-
stderr: [WARNING] Providing the CQL statement as a positional parameter is deprecated and will be removed in future versions.
10-
stderr: [WARNING] Please use the 'astra db cqlsh exec -e "CQL STATEMENT"' syntax instead.
119
stdout: code,message,exit_code,stdout,stderr
1210
stdout: OK,"Cqlsh executed with exit code 2, with 1 lines in stdout and 1 lines in stderr.",2,,<stdin>:1:'cars' not found in keyspaces
1311
---- end ----

src/test/resources/snapshots/_db/_cqlsh/CqlshExecCmd/exec_string_fail.csv.received.txt

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---- meta ----
2-
command: astra db cqlsh exec two_regions_db 'DESC CARS'
2+
command: astra db cqlsh exec two_regions_db -e 'DESC CARS'
33
exit_code: 2
44
comments:
55
| Can't really test human output since we don't capture cqlsh output for human outputs
66
| But at least we can verify the command runs and the exit code is correct
77
| (human output returns cqlsh exit code; non-human output returns the cqlsh exit code via a field)
88
---- output ----
9-
stderr: [WARNING] Providing the CQL statement as a positional parameter is deprecated and will be removed in future versions.
10-
stderr: [WARNING] Please use the 'astra db cqlsh exec -e "CQL STATEMENT"' syntax instead.
119
---- end ----

src/test/resources/snapshots/_db/_cqlsh/CqlshExecCmd/exec_string_fail.human.received.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)