Skip to content

Commit

Permalink
test: fix redis node username output
Browse files Browse the repository at this point in the history
  • Loading branch information
levisingularity committed Jun 27, 2024
1 parent 5e721f4 commit 55354bb
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions tests/integration/test_db.bats
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ setup() {
@test "Starting mongodb and redis standalone" {
local mongodb_port="$(get_config ".mongodb.port")"
local redis_port="$(get_config .redis.port)"
local redis_node1_username="$(get_config ".redis.nodes[0].username")"

run das-cli db start

assert_output "Starting Redis service...
Redis has started successfully on port ${redis_port} at localhost, operating under the user ${current_user}.
Redis has started successfully on port ${redis_port} at localhost, operating under the user ${redis_node1_username}.
Starting MongoDB service...
MongoDB started on port ${mongodb_port}"

Expand All @@ -44,13 +45,14 @@ MongoDB started on port ${mongodb_port}"
@test "It should gives up a warning when db is already up" {
local mongodb_port="$(get_config ".mongodb.port")"
local redis_port="$(get_config .redis.port)"
local redis_node1_username="$(get_config ".redis.nodes[0].username")"

das-cli db start

run das-cli db start

assert_output "Starting Redis service...
Redis is already running. It is currently listening on port ${redis_port} at IP address localhost under the user ${current_user}.
Redis is already running. It is currently listening on port ${redis_port} at IP address localhost under the user ${redis_node1_username}.
Starting MongoDB service...
MongoDB is already running. It's listening on port ${mongodb_port}"

Expand All @@ -66,14 +68,15 @@ MongoDB is already running. It's listening on port ${mongodb_port}"
local redis_port="$(get_config .redis.port)"
local redis_container_name="$(get_config .redis.container_name)"
local mongodb_container_name="$(get_config .mongodb.container_name)"
local redis_node1_username="$(get_config ".redis.nodes[0].username")"

run das-cli db restart

assert_output "Stopping redis service...
The Redis service named ${redis_container_name} at localhost is already stopped by the ${current_user} user.
The Redis service named ${redis_container_name} at localhost is already stopped by the ${redis_node1_username} user.
The MongoDB service named ${mongodb_container_name} is already stopped.
Starting Redis service...
Redis has started successfully on port ${redis_port} at localhost, operating under the user ${current_user}.
Redis has started successfully on port ${redis_port} at localhost, operating under the user ${redis_node1_username}.
Starting MongoDB service...
MongoDB started on port ${mongodb_port}"

Expand All @@ -87,16 +90,17 @@ MongoDB started on port ${mongodb_port}"
@test "It should restart db successfully when db is already up" {
local mongodb_port="$(get_config ".mongodb.port")"
local redis_port="$(get_config .redis.port)"
local redis_node1_username="$(get_config ".redis.nodes[0].username")"

das-cli db start

run das-cli db restart

assert_output "Stopping redis service...
The Redis service at localhost has been stopped by the ${current_user} user
The Redis service at localhost has been stopped by the ${redis_node1_username} user
MongoDB service stopped
Starting Redis service...
Redis has started successfully on port ${redis_port} at localhost, operating under the user ${current_user}.
Redis has started successfully on port ${redis_port} at localhost, operating under the user ${redis_node1_username}.
Starting MongoDB service...
MongoDB started on port ${mongodb_port}"

Expand All @@ -108,12 +112,14 @@ MongoDB started on port ${mongodb_port}"
}

@test "It should stop db successfully" {
local redis_node1_username="$(get_config ".redis.nodes[0].username")"

das-cli db start &>/dev/null

run das-cli db stop

assert_output "Stopping redis service...
The Redis service at localhost has been stopped by the ${current_user} user
The Redis service at localhost has been stopped by the ${redis_node1_username} user
MongoDB service stopped"

run is_service_up redis
Expand All @@ -126,11 +132,12 @@ MongoDB service stopped"
@test "It should warns up when db is already stopped" {
local redis_container_name="$(get_config .redis.container_name)"
local mongodb_container_name="$(get_config .mongodb.container_name)"
local redis_node1_username="$(get_config ".redis.nodes[0].username")"

run das-cli db stop

assert_output "Stopping redis service...
The Redis service named ${redis_container_name} at localhost is already stopped by the ${current_user} user.
The Redis service named ${redis_container_name} at localhost is already stopped by the ${redis_node1_username} user.
The MongoDB service named ${mongodb_container_name} is already stopped."

run is_service_up redis
Expand Down

0 comments on commit 55354bb

Please sign in to comment.