Skip to content

Commit

Permalink
Refactor and clean-up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kishen-v committed May 16, 2024
1 parent 240e15a commit c66b0bd
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 114 deletions.
7 changes: 4 additions & 3 deletions cmd/image/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-100
if err != nil {
return err
}
var accessKey string
var accessSecret string
var accessKey, accessSecret string

//Create AccessKey and SecretKey for the bucket provided if bucket access is private
if (opt.AccessKey == "" || opt.SecretKey == "") && (!opt.Public) {
Expand All @@ -106,7 +105,9 @@ pvsadm image import -n upstream-core-lon04 -b <BUCKETNAME> --object rhel-83-100
if err != nil {
return fmt.Errorf("failed to list the resource instances: %v", err)
}

if len(workspaces.Resources) == 0 {
return fmt.Errorf("there are no resouces under the resource instance shared")
}
getServiceInstanceOptions := &resourcecontrollerv2.GetResourceInstanceOptions{
// TODO: possibility of workspaces to either be of type service_instance or composite_instance.
ID: workspaces.Resources[0].ID,
Expand Down
7 changes: 0 additions & 7 deletions cmd/image/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ const (
CosResourceID = "dff97f5c-bc5e-4455-b470-411c3edbe49c"
)

// CosResourcePlanID is IBM COS plan id, can be retrieved using ibmcloud cli
var CosResourcePlans = map[string]string{
"onerate": "1e4e33e4-cfa6-4f12-9016-be594a6d5f87",
"lite": "2fdf0c08-2d32-4f46-84b5-32e0c92fffd8",
"standard": "744bfc56-d12c-4866-88d5-dac9139e0e5d",
}

var Cmd = &cobra.Command{
Use: "upload",
Short: "Upload the image to the IBM COS",
Expand Down
5 changes: 1 addition & 4 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ func (c *Client) CreateServiceInstance(instanceName, serviceName, resourcePlan,
if err != nil {
return nil, err
}

klog.Infof("Resource service Instance Details :%+v\n", resp)
klog.Infof("Resource service InstanceID :%v\n", resp.ID)

klog.Infof("Created service instance %s of %s-%s in %s", instanceName, serviceName, resourcePlan, region)
return resp, nil
}

Expand Down
9 changes: 5 additions & 4 deletions test/e2e/qcow2ova/qcow2ova.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ func runImageQcow2OvaCMD(args ...string) (int, string, string) {
var _ = CMDDescribe("pvsadm qcow2ova tests", func() {
var (
image *os.File
err error
)

BeforeSuite(func() {
var err error
Expect(os.Getenv("IBMCLOUD_API_KEY")).NotTo(BeEmpty(), "IBMCLOUD_API_KEY must be set before running \"make test\"")
image, err = os.CreateTemp("", "qcow2ova")
Expect(err).NotTo(HaveOccurred())
_, err = image.WriteString("some dummy image")
Expand All @@ -50,16 +51,16 @@ var _ = CMDDescribe("pvsadm qcow2ova tests", func() {
status, stdout, stderr := runImageQcow2OvaCMD(
"--help",
)
Expect(status).To(Equal(0))
Expect(stderr).To(Equal(""))
Expect(status).To(BeZero())
Expect(stderr).To(BeEmpty())
Expect(stdout).To(ContainSubstring("Examples:"))
})

framework.NegativeIt("run without image-dist", func() {
status, _, stderr := runImageQcow2OvaCMD(
"--image-url", image.Name(),
)
Expect(status).NotTo(Equal(0))
Expect(status).NotTo(BeZero())
Expect(stderr).To(ContainSubstring("image-dist is a mandatory flag"))
})
})
Loading

0 comments on commit c66b0bd

Please sign in to comment.