-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from uselagoon/feature/fix_port_and_add_tests_…
…for_sync_command Fixes logic error with ssh port and introduces regression test
- Loading branch information
Showing
5 changed files
with
317 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"github.com/spf13/cobra" | ||
"github.com/uselagoon/lagoon-sync/synchers" | ||
"testing" | ||
) | ||
|
||
func Test_syncCommandRun(t *testing.T) { | ||
type args struct { | ||
cmd *cobra.Command | ||
args []string | ||
} | ||
tests := []struct { | ||
name string | ||
lagoonYmlFile string | ||
args args | ||
runSyncProcess synchers.RunSyncProcessFunctionType //This will be the thing that drives the actual test | ||
wantsError bool | ||
}{ | ||
{ | ||
name: "Tests defaults", | ||
lagoonYmlFile: "../test-resources/sync-test/tests-defaults/.lagoon.yml", | ||
args: args{ | ||
cmd: nil, | ||
args: []string{ | ||
"mariadb", | ||
}, | ||
}, | ||
runSyncProcess: func(sourceEnvironment synchers.Environment, targetEnvironment synchers.Environment, lagoonSyncer synchers.Syncer, syncerType string, dryRun bool, sshOptions synchers.SSHOptions) error { | ||
if sshOptions.Port != "32222" { | ||
return errors.New(fmt.Sprintf("Expecting ssh port 32222 - found: %v", sshOptions.Port)) | ||
} | ||
|
||
if sshOptions.Host != "ssh.lagoon.amazeeio.cloud" { | ||
return errors.New(fmt.Sprintf("Expecting ssh host ssh.lagoon.amazeeio.cloud - found: %v", sshOptions.Host)) | ||
} | ||
|
||
return nil | ||
}, | ||
wantsError: false, | ||
}, | ||
{ | ||
name: "Tests Lagoon yaml", | ||
lagoonYmlFile: "../test-resources/sync-test/tests-lagoon-yml/.lagoon.yml", | ||
args: args{ | ||
cmd: nil, | ||
args: []string{ | ||
"mariadb", | ||
}, | ||
}, | ||
runSyncProcess: func(sourceEnvironment synchers.Environment, targetEnvironment synchers.Environment, lagoonSyncer synchers.Syncer, syncerType string, dryRun bool, sshOptions synchers.SSHOptions) error { | ||
if sshOptions.Port != "777" { | ||
return errors.New(fmt.Sprintf("Expecting ssh port 777 - found: %v", sshOptions.Port)) | ||
} | ||
|
||
if sshOptions.Host != "example.ssh.lagoon.amazeeio.cloud" { | ||
return errors.New(fmt.Sprintf("Expecting ssh host ssh.lagoon.amazeeio.cloud - found: %v", sshOptions.Host)) | ||
} | ||
|
||
return nil | ||
}, | ||
wantsError: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
runSyncProcess = tt.runSyncProcess | ||
cfgFile = tt.lagoonYmlFile | ||
noCliInteraction = true | ||
syncCommandRun(tt.args.cmd, tt.args.args) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Example .lagoon.yml file with lagoon-sync config added which is used by the sync tool. | ||
docker-compose-yaml: docker-compose.yml | ||
|
||
project: "lagoon-sync" | ||
|
||
lagoon-sync: | ||
mariadb: | ||
config: | ||
hostname: "$MARIADB_HOST" | ||
username: "$MARIADB_USERNAME" | ||
password: "$MARIADB_PASSWORD" | ||
port: "$MARIADB_PORT" | ||
database: "$MARIADB_DATABASE" | ||
ignore-table: | ||
- "table_to_ignore" | ||
ignore-table-data: | ||
- "cache_data" | ||
- "cache_menu" | ||
local: | ||
config: | ||
hostname: "mariadb" | ||
username: "drupal" | ||
password: "drupal" | ||
port: "3306" | ||
database: "drupal" | ||
postgres: | ||
config: | ||
hostname: "$POSTGRES_HOST" | ||
username: "$POSTGRES_USERNAME" | ||
password: "$POSTGRES_PASSWORD" | ||
port: "5432" | ||
database: "$POSTGRES_DATABASE" | ||
exclude-table: | ||
- "table_to_ignore" | ||
exclude-table-data: | ||
- "cache_data" | ||
- "cache_menu" | ||
local: | ||
config: | ||
hostname: "postgres" | ||
username: "drupal" | ||
password: "drupal" | ||
port: "3306" | ||
database: "drupal" | ||
mongodb: | ||
config: | ||
hostname: "$MONGODB_HOST" | ||
port: "$MONGODB_SERVICE_PORT" | ||
database: "MONGODB_DATABASE" | ||
local: | ||
config: | ||
hostname: "$MONGODB_HOST" | ||
port: "27017" | ||
database: "local" | ||
files: | ||
config: | ||
sync-directory: "/app/web/sites/default/files" | ||
local: | ||
config: | ||
sync-directory: "/app/web/sites/default/files" | ||
drupalconfig: | ||
config: | ||
syncpath: "./config/sync" | ||
local: | ||
overrides: | ||
config: | ||
syncpath: "./config/sync" |
Oops, something went wrong.