Skip to content

Commit

Permalink
♻️ : extract test data creation
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed Jul 5, 2019
1 parent 6efd602 commit 5e2e310
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions src/main/java/io/codeka/gaia/Gaia.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import java.util.List;
import java.util.UUID;

@SpringBootApplication
@EnableMongoRepositories
Expand All @@ -35,27 +34,7 @@ CommandLineRunner cli(TerraformModuleRepository repository,
stackRepository.deleteAll();

// create dummy module for tests
var module = new TerraformModule();
module.setId("e01f9925-a559-45a2-8a55-f93dc434c676");
module.setName("terraform-docker-mongo");
module.setDescription("A sample terraform \uD83C\uDF0D module for running a mongodb \uD83C\uDF43 database inside a docker \uD83D\uDC33 container");
module.setGitRepositoryUrl("https://github.com/juwit/terraform-docker-mongo.git");
module.setDirectory("");
module.setGitBranch("master");

var tvar = new TerraformVariable();
tvar.setName("mongo_container_name");
tvar.setDescription("the name of the docker container");

var tvar2 = new TerraformVariable();
tvar2.setName("mongo_exposed_port");
tvar2.setDescription("the exposed port of the mongo container");
tvar2.setDefaultValue("27017");

module.setVariables(List.of(tvar, tvar2));

repository.saveAll(List.of(module));

repository.saveAll(List.of(buildDockerMongoModule()));

var stack = new Stack();
stack.setId("5a215b6b-fe53-4afa-85f0-a10175a7f264");
Expand All @@ -64,7 +43,7 @@ CommandLineRunner cli(TerraformModuleRepository repository,
stack.setModuleId("e01f9925-a559-45a2-8a55-f93dc434c676");
stack.getVariableValues().put("mongo_container_name", "test");
stack.getVariableValues().put("mongo_exposed_port", "27117");
stack.setProviderSpec("provider \"poulp\" {\n" +
stack.setProviderSpec("provider \"docker\" {\n" +
" host = \"unix:///var/run/docker.sock\"\n" +
"}");
stackRepository.save(stack);
Expand All @@ -78,4 +57,28 @@ CommandLineRunner cli(TerraformModuleRepository repository,
};
}

private TerraformModule buildDockerMongoModule() {
var module = new TerraformModule();
module.setId("e01f9925-a559-45a2-8a55-f93dc434c676");
module.setName("terraform-docker-mongo");
module.setDescription("A sample terraform \uD83C\uDF0D module for running a mongodb \uD83C\uDF43 database inside a docker \uD83D\uDC33 container");
module.setGitRepositoryUrl("https://github.com/juwit/terraform-docker-mongo.git");
module.setDirectory("");
module.setGitBranch("master");

var tvar = new TerraformVariable();
tvar.setName("mongo_container_name");
tvar.setDescription("the name of the docker container");
tvar.setEditable(true);

var tvar2 = new TerraformVariable();
tvar2.setName("mongo_exposed_port");
tvar2.setDescription("the exposed port of the mongo container");
tvar2.setDefaultValue("27017");
tvar2.setEditable(true);

module.setVariables(List.of(tvar, tvar2));
return module;
}

}

0 comments on commit 5e2e310

Please sign in to comment.