mirror of
https://github.com/aljazceru/nigiri.git
synced 2026-02-04 06:14:57 +01:00
* changes for new version of esplora image * add electrs port and esplora url env vars in compose yaml files * wrap viper methods into Config type and use constants package * add controller to interact with nigiri resources: * .env for docker-compose * docker daemon * json config file * add use of constants and config packages and change start flag from --port to --env * add package for global constants and variables * add use of controller and constants packages instead of local methods and vars * bump version * use contants in logs command tests
85 lines
1.9 KiB
Go
85 lines
1.9 KiB
Go
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/vulpemventures/nigiri/cli/constants"
|
|
)
|
|
|
|
var (
|
|
serviceList = []string{"node", "electrs", "esplora", "chopsticks"}
|
|
)
|
|
|
|
func TestLogBitcoinServices(t *testing.T) {
|
|
if err := testCommand("start", "", bitcoin); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
for _, service := range serviceList {
|
|
if err := testCommand("logs", service, bitcoin); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if err := testCommand("stop", "", delete); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestLogLiquidServices(t *testing.T) {
|
|
if err := testCommand("start", "", liquid); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
for _, service := range serviceList {
|
|
if err := testCommand("logs", service, liquid); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
if err := testCommand("stop", "", delete); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestLogShouldFail(t *testing.T) {
|
|
expectedError := constants.ErrNigiriNotRunning.Error()
|
|
|
|
err := testCommand("logs", serviceList[0], bitcoin)
|
|
if err == nil {
|
|
t.Fatal("Should return error when Nigiri is stopped")
|
|
}
|
|
if err.Error() != expectedError {
|
|
t.Fatalf("Expected error: %s, got: %s", expectedError, err)
|
|
}
|
|
|
|
err = testCommand("logs", serviceList[0], liquid)
|
|
if err == nil {
|
|
t.Fatal("Should return error when Nigiri is stopped")
|
|
}
|
|
if err.Error() != expectedError {
|
|
t.Fatalf("Expected error: %s, got: %s", expectedError, err)
|
|
}
|
|
}
|
|
|
|
func TestStartBitcoinAndLogNigiriServicesShouldFail(t *testing.T) {
|
|
if err := testCommand("start", "", bitcoin); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
expectedError := constants.ErrNigiriLiquidNotEnabled.Error()
|
|
|
|
err := testCommand("logs", serviceList[0], liquid)
|
|
if err == nil {
|
|
t.Fatal("Should return error when trying logging liquid services if not running")
|
|
}
|
|
|
|
if err.Error() != expectedError {
|
|
t.Fatalf("Expected error: %s, got: %s", expectedError, err)
|
|
}
|
|
|
|
if err := testCommand("stop", "", delete); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|