github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/tests/network_test.go (about)

     1  package tests
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/pterm/pterm"
     7  	"github.com/taubyte/tau-cli/common"
     8  	"github.com/taubyte/tau-cli/constants"
     9  )
    10  
    11  func TestNetworkAll(t *testing.T) {
    12  	runTests(t, createNetworkMonkey(), true)
    13  }
    14  
    15  func createNetworkMonkey() *testSpider {
    16  	// Define shared variables
    17  	profileName := "test"
    18  	projectName := "test_project"
    19  	fqdn := "sandbox.taubyte.com"
    20  
    21  	// The config that will be written
    22  	getConfigString := basicGetConfigString(profileName, projectName)
    23  
    24  	// Run before each test
    25  	beforeEach := func(tt testMonkey) [][]string {
    26  		tt.env[constants.CurrentSelectedNetworkName] = ""
    27  		return nil
    28  	}
    29  
    30  	// TODO: Add a dreamland test that starts and stop a dreamland instance
    31  	tests := []testMonkey{
    32  		{
    33  			// FIXME: this test passes with debug being true for some reason
    34  			name: "Select Remote network",
    35  			args: []string{"select", "network", "--fqdn", fqdn},
    36  			wantOut: []string{
    37  				pterm.Success.Sprintf("Connected to %s", pterm.FgCyan.Sprintf(fqdn)),
    38  			},
    39  			evaluateSession: expectedSelectedCustomNetwork(common.RemoteNetwork, fqdn),
    40  			debug:           true,
    41  		},
    42  
    43  		{
    44  			name:            "Select login with network saved",
    45  			args:            []string{"login", "--name", profileName},
    46  			evaluateSession: expectedSelectedNetwork(common.RemoteNetwork),
    47  		},
    48  	}
    49  
    50  	return &testSpider{projectName, tests, beforeEach, getConfigString, "network"}
    51  }