package cmdstr_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/pingcap/endless/pkg/workloadnode/cmdstr"
)

var _ = Describe("BR", func() {

	It("should has correct string reprensentation", func() {
		s := cmdstr.NewBR("/br").
			BackupFull().
			String()
		Expect(s).To(Equal("/br backup full"))
	})

	It("should work with options", func() {
		var opts cmdstr.BROptions
		opts.Storage = "s3://brie/cc/xx?access-key=key&secret-access-key=secret"
		opts.PD = []string{"127.0.0.1:2379", "127.0.0.1:22379"}
		s := cmdstr.NewBR("/go-ycsb").
			RestoreFull().
			CommonOptions(&opts).
			String()
		Expect(s).To(ContainSubstring(`--pd 127.0.0.1:22379`))
		Expect(s).To(ContainSubstring(`--storage "` + opts.Storage + `"`))
	})
})
