github.com/Benchkram/bob@v0.0.0-20220321080157-7c8f3876e225/bob/bobfile/bobfile_test.go (about)

     1  package bobfile_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/Benchkram/bob/bob/bobfile"
     7  	"github.com/Benchkram/bob/bobrun"
     8  	"github.com/Benchkram/bob/bobtask"
     9  )
    10  
    11  func TestBobfileValidateSelReference(t *testing.T) {
    12  	b := bobfile.NewBobfile()
    13  
    14  	b.BTasks["one"] = bobtask.Task{
    15  		DependsOn: []string{"one"},
    16  	}
    17  
    18  	if err := b.Validate(); err == nil {
    19  		t.Error("Expected error, got nil")
    20  	}
    21  }
    22  
    23  func TestBobfileValidateDuplicateName(t *testing.T) {
    24  	b := bobfile.NewBobfile()
    25  
    26  	b.BTasks["one"] = bobtask.Task{}
    27  
    28  	b.RTasks["one"] = &bobrun.Run{}
    29  
    30  	if err := b.Validate(); err == nil {
    31  		t.Error("Expected error, got nil")
    32  	}
    33  }
    34  
    35  func TestBobfileValidateInvalidVersion(t *testing.T) {
    36  	b := bobfile.NewBobfile()
    37  
    38  	b.Version = "invalid-version"
    39  
    40  	if err := b.Validate(); err == nil {
    41  		t.Error("Expected error, got nil")
    42  	}
    43  }
    44  
    45  func TestBobfileValidateValidVersion(t *testing.T) {
    46  	b := bobfile.NewBobfile()
    47  
    48  	b.Version = "1.2.3"
    49  
    50  	if err := b.Validate(); err != nil {
    51  		t.Error("Expected nil, got error")
    52  	}
    53  }