-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added BDD test using Ginkgo and Gomega * Try new cmd tree * New CLI structure * Add Ginkgo test * Add Ginkgo Action * Change ginkgo install cmd * Date different for TZ * Finish rebasing
- Loading branch information
Etourneau Gwenn
authored
Jan 31, 2023
1 parent
d84621c
commit 369907c
Showing
46 changed files
with
1,367 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ jobs: | |
ssh-add - <<< '${{ secrets.GO_CLIENT_SECRET }}' | ||
git config --global url."[email protected]:".insteadOf https://github.com/ | ||
make vet | ||
make test | ||
make build | ||
make clean | ||
name: Build CLI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package cmd_test | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"os" | ||
"os/exec" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/onsi/gomega/gbytes" | ||
"github.com/onsi/gomega/gexec" | ||
"github.com/onsi/gomega/ghttp" | ||
"github.com/yugabyte/ybm-cli/internal/formatter" | ||
openapi "github.com/yugabyte/yugabytedb-managed-go-client-internal" | ||
) | ||
|
||
var _ = Describe("Backup", func() { | ||
|
||
var ( | ||
server *ghttp.Server | ||
statusCode int | ||
args []string | ||
responseAccount openapi.AccountListResponse | ||
responseProject openapi.ProjectListResponse | ||
responseBackup openapi.BackupListResponse | ||
//cbr *cobra.Command | ||
) | ||
|
||
BeforeEach(func() { | ||
args = os.Args | ||
os.Args = []string{} | ||
var err error | ||
server, err = newGhttpServer(responseAccount, responseProject) | ||
Expect(err).ToNot(HaveOccurred()) | ||
os.Setenv("YBM_HOST", fmt.Sprintf("http://%s", server.Addr())) | ||
os.Setenv("YBM_APIKEY", "test-token") | ||
}) | ||
|
||
Context("When running with a valid Api token", func() { | ||
|
||
It("should return list of available backup", func() { | ||
statusCode = 200 | ||
err := loadJson("./test/fixtures/backups.json", &responseBackup) | ||
Expect(err).ToNot(HaveOccurred()) | ||
server.AppendHandlers( | ||
ghttp.CombineHandlers( | ||
ghttp.VerifyRequest(http.MethodGet, "/api/public/v1/accounts/340af43a-8a7c-4659-9258-4876fd6a207b/projects/78d4459c-0f45-47a5-899a-45ddf43eba6e/backups"), | ||
ghttp.RespondWithJSONEncodedPtr(&statusCode, responseBackup), | ||
), | ||
) | ||
cmd := exec.Command(compiledCLIPath, "backup", "get") | ||
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) | ||
Expect(err).NotTo(HaveOccurred()) | ||
session.Wait(2) | ||
Expect(session.Out).Should(gbytes.Say(fmt.Sprintf( | ||
`Created On Expire On Clusters Description State Type Retains\(day\) | ||
%s %s proficient-parrotfish scdasfdadfasdsad SUCCEEDED MANUAL 25`, formatter.FormatDate("2023-01-17T08:31:35.818Z"), formatter.FormatDate("2023-01-17T08:31:35.818Z")))) | ||
session.Kill() | ||
}) | ||
|
||
}) | ||
|
||
AfterEach(func() { | ||
os.Args = args | ||
server.Close() | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.