Skip to content

Commit 4ec3b95

Browse files
committed
Fix fixture double-consumption in resolveHostMetadata tests
resolve() internally calls tryResolveHostMetadata() which consumes a fixture from the FixtureServer. Tests that then explicitly call resolveHostMetadata() need a second fixture registered to avoid server returning an unexpected response.
1 parent eda1c18 commit 4ec3b95

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

databricks-sdk-java/src/test/java/com/databricks/sdk/core/DatabricksConfigTest.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,9 @@ public void testResolveHostMetadataPopulatesResolvedHostType() throws IOExceptio
668668
+ "\","
669669
+ "\"host_type\":\"workspace\"}";
670670
try (FixtureServer server =
671-
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
671+
new FixtureServer()
672+
.with("GET", "/.well-known/databricks-config", response, 200)
673+
.with("GET", "/.well-known/databricks-config", response, 200)) {
672674
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
673675
config.resolve(emptyEnv());
674676
config.resolveHostMetadata();
@@ -685,7 +687,9 @@ public void testResolveHostMetadataDoesNotOverwriteExistingHostType() throws IOE
685687
+ "\","
686688
+ "\"host_type\":\"workspace\"}";
687689
try (FixtureServer server =
688-
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
690+
new FixtureServer()
691+
.with("GET", "/.well-known/databricks-config", response, 200)
692+
.with("GET", "/.well-known/databricks-config", response, 200)) {
689693
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
690694
config.resolve(emptyEnv());
691695
config.setResolvedHostType(HostType.UNIFIED);
@@ -703,7 +707,9 @@ public void testResolveHostMetadataUnknownHostTypeIgnored() throws IOException {
703707
+ "\","
704708
+ "\"host_type\":\"unknown_value\"}";
705709
try (FixtureServer server =
706-
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
710+
new FixtureServer()
711+
.with("GET", "/.well-known/databricks-config", response, 200)
712+
.with("GET", "/.well-known/databricks-config", response, 200)) {
707713
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
708714
config.resolve(emptyEnv());
709715
config.resolveHostMetadata();
@@ -720,7 +726,9 @@ public void testResolveHostMetadataHostTypeAccount() throws IOException {
720726
+ "\","
721727
+ "\"host_type\":\"account\"}";
722728
try (FixtureServer server =
723-
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
729+
new FixtureServer()
730+
.with("GET", "/.well-known/databricks-config", response, 200)
731+
.with("GET", "/.well-known/databricks-config", response, 200)) {
724732
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
725733
config.resolve(emptyEnv());
726734
config.resolveHostMetadata();
@@ -737,7 +745,9 @@ public void testResolveHostMetadataHostTypeUnified() throws IOException {
737745
+ "\","
738746
+ "\"host_type\":\"unified\"}";
739747
try (FixtureServer server =
740-
new FixtureServer().with("GET", "/.well-known/databricks-config", response, 200)) {
748+
new FixtureServer()
749+
.with("GET", "/.well-known/databricks-config", response, 200)
750+
.with("GET", "/.well-known/databricks-config", response, 200)) {
741751
DatabricksConfig config = new DatabricksConfig().setHost(server.getUrl());
742752
config.resolve(emptyEnv());
743753
config.resolveHostMetadata();

0 commit comments

Comments
 (0)