github.com/azure/draft-classic@v0.16.0/pkg/draft/pack/repo/builtins_test.go (about)

     1  package repo
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/Azure/draft/pkg/version"
     7  )
     8  
     9  const stableRelease = "v1.0.0"
    10  
    11  func TestBuiltins(t *testing.T) {
    12  	version.Release = "canary"
    13  
    14  	builtins := Builtins()
    15  	if len(builtins) != 1 {
    16  		t.Errorf("expected 1 builtin, got %d", len(builtins))
    17  	}
    18  
    19  	if builtins[0].URL != "https://github.com/Azure/draft" {
    20  		t.Error("expected https://github.com/Azure/draft to be in the builtin list")
    21  	}
    22  
    23  	if builtins[0].Name != "github.com/Azure/draft" {
    24  		t.Error("expected github.com/Azure/draft to be in the builtin list")
    25  	}
    26  
    27  	if builtins[0].Version != "" {
    28  		t.Error("expected version to be an empty string when the current draft release is a canary release")
    29  	}
    30  
    31  	version.Release = stableRelease
    32  
    33  	builtins = Builtins()
    34  
    35  	if builtins[0].Version != stableRelease {
    36  		t.Errorf("expected version to be '%s'; got '%s'", stableRelease, builtins[0].Version)
    37  	}
    38  }