github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/lib/repository/info_test.go (about)

     1  package repositoryLib_test
     2  
     3  import (
     4  	"fmt"
     5  	"strconv"
     6  	"testing"
     7  
     8  	commonTest "github.com/taubyte/tau-cli/common/test"
     9  	repositoryLib "github.com/taubyte/tau-cli/lib/repository"
    10  	"github.com/taubyte/tau-cli/singletons/session"
    11  	"gotest.tools/v3/assert"
    12  )
    13  
    14  func TestInfo(t *testing.T) {
    15  	assert.NilError(t, session.Set().ProfileName("taubytetest"))
    16  	assert.NilError(t, session.Set().SelectedNetwork("Remote"))
    17  	assert.NilError(t, session.Set().CustomNetworkUrl("sandbox.taubyte.com"))
    18  
    19  	info := &repositoryLib.Info{
    20  		ID:   strconv.Itoa(commonTest.ConfigRepo.ID),
    21  		Type: repositoryLib.WebsiteRepositoryType,
    22  	}
    23  
    24  	assert.NilError(t, info.GetNameFromID())
    25  
    26  	expectedFullName := fmt.Sprintf("%s/%s", commonTest.GitUser, commonTest.ConfigRepo.Name)
    27  
    28  	if info.FullName != expectedFullName {
    29  		t.Errorf("Expected %s, got %s", expectedFullName, info.FullName)
    30  		return
    31  	}
    32  
    33  	info.ID = ""
    34  	assert.NilError(t, info.GetIDFromName())
    35  
    36  	expectedID := commonTest.ConfigRepo.ID
    37  	if info.ID != strconv.Itoa(expectedID) {
    38  		t.Errorf("Expected %d, got %s", expectedID, info.ID)
    39  		return
    40  	}
    41  }