github.com/benchkram/bob@v0.0.0-20240314204020-b7a57f2f9be9/test/e2e/init/init_test.go (about)

     1  package inittest
     2  
     3  import (
     4  	"errors"
     5  
     6  	"github.com/benchkram/bob/bob"
     7  	. "github.com/onsi/ginkgo"
     8  	. "github.com/onsi/gomega"
     9  
    10  	"github.com/benchkram/bob/pkg/file"
    11  )
    12  
    13  var _ = Describe("Test bob init", func() {
    14  	Context("in a fresh environment", func() {
    15  		It("initializes bob", func() {
    16  			Expect(b.Init()).NotTo(HaveOccurred())
    17  		})
    18  
    19  		It("check that .bob dir exists", func() {
    20  			Expect(file.Exists(".bob.workspace")).To(BeTrue())
    21  		})
    22  
    23  		It("check that bob fails gracefully if .bob already exists", func() {
    24  			err := b.Init()
    25  			Expect(err).To(HaveOccurred())
    26  			unwrappedErr := errors.Unwrap(err)
    27  			Expect(unwrappedErr).NotTo(BeNil())
    28  			Expect(errors.Is(unwrappedErr, bob.ErrWorkspaceAlreadyInitialised)).To(BeTrue())
    29  		})
    30  	})
    31  })