github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/core/model/model_test.go (about)

     1  // Copyright 2018 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package model_test
     5  
     6  import (
     7  	"github.com/juju/errors"
     8  	"github.com/juju/testing"
     9  	jc "github.com/juju/testing/checkers"
    10  	gc "gopkg.in/check.v1"
    11  
    12  	"github.com/juju/juju/core/model"
    13  )
    14  
    15  type ModelSuite struct {
    16  	testing.IsolationSuite
    17  }
    18  
    19  var _ = gc.Suite(&ModelSuite{})
    20  
    21  func (*ModelSuite) TestValidateBranchName(c *gc.C) {
    22  	for _, t := range []struct {
    23  		branchName string
    24  		valid      bool
    25  	}{
    26  		{"", false},
    27  		{model.GenerationMaster, false},
    28  		{"something else", true},
    29  	} {
    30  		err := model.ValidateBranchName(t.branchName)
    31  		if t.valid {
    32  			c.Check(err, jc.ErrorIsNil)
    33  		} else {
    34  			c.Check(err, jc.Satisfies, errors.IsNotValid)
    35  		}
    36  	}
    37  }