From 475239374870598e955d4a70a262c9ede1debdf7 Mon Sep 17 00:00:00 2001 From: Karl Cardenas <29551334+karl-cardenas-coding@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:43:54 -0700 Subject: [PATCH] feat: v1.0.0 release (#17) --- README.md | 4 +- cmd/version.go | 164 +------------------ cmd/version_test.go | 374 -------------------------------------------- 3 files changed, 3 insertions(+), 539 deletions(-) delete mode 100644 cmd/version_test.go diff --git a/README.md b/README.md index 8a78bb9..dd40586 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ MyWhoop supports extensions for data exporters and notification services. Export | Name | Description | Configuration | |---|---| --- | | File | This is the default exporter. The exporter saves the Whoop data to a local file. | [File Exporter](./docs/configuration_reference.md#file-export) | -| [AWS S3](https://aws.amazon.com/s3/) | The AWS S3 exporter saves the Whoop data to an S3 bucket. | [AWS S3 Exporter](./docs/configuration_reference.md#s3-export) | +| AWS S3 | The [AWS S3](https://aws.amazon.com/s3/) exporter saves the Whoop data to an S3 bucket. | [AWS S3 Exporter](./docs/configuration_reference.md#s3-export) | @@ -164,4 +164,4 @@ MyWhoop supports extensions for data exporters and notification services. Export | Name | Description | Configuration | |---|---| --- | | stdout | The stdout notification is the default notification mechanism. Output is sent to the console. | [Stdout](./docs/configuration_reference.md#notification) | -| [Ntfy](https://ntfy.sh/) | Use the Ntfy notification service to send notifications to your phone or desktop. | [Ntfy](./docs/configuration_reference.md#ntfy) | \ No newline at end of file +| Ntfy | Use the [Ntfy](https://ntfy.sh/) notification service to send notifications to your phone or desktop. | [Ntfy](./docs/configuration_reference.md#ntfy) | \ No newline at end of file diff --git a/cmd/version.go b/cmd/version.go index f8d320f..3bbf44b 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -4,23 +4,12 @@ package cmd import ( - "encoding/json" "fmt" "log/slog" - "net/http" - "time" - "github.com/hashicorp/go-version" - "github.com/karl-cardenas-coding/mywhoop/internal" "github.com/spf13/cobra" ) -const ( - url = "https://api.github.com/repos/karl-cardenas-coding/mywhoop/releases/latest" - // IssueMSG is a default message to pass to the user - IssueMSG = " Please open up a GitHub issue to report this error. https://github.com/karl-cardenas-coding/mywhoop" -) - func init() { rootCmd.AddCommand(VersionCmd) } @@ -32,157 +21,6 @@ var VersionCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { version := fmt.Sprintf("mywhoop v%s", VersionString) slog.Info(version) - client := internal.CreateHTTPClient() - _, message, err := checkForNewRelease(client, VersionString, UserAgent, url) - if err != nil { - slog.Error("Error checking for new release", "msg", err) - return err - } - slog.Info(message) - return err + return nil }, } - -func checkForNewRelease(client *http.Client, currentVersion, useragent, url string) (bool, string, error) { - var ( - output bool - message string - release release - ) - - slog.Info("Checking for new releases") - req, err := http.NewRequest("GET", url, nil) - if err != nil { - slog.Error("Error creating new HTTP request", "msg", err) - return output, message, err - } - req.Header.Set("Accept", "application/vnd.github.v3+json") - req.Header.Set("User-Agent", useragent) - resp, err := client.Do(req) - if err != nil { - slog.Error("Error initaiting connection to", url, err) - return output, message, err - } - - if resp != nil && resp.Body != nil { - defer resp.Body.Close() - - if resp.StatusCode != http.StatusOK { - msg := fmt.Sprintf("Error status code from Github - %d", resp.StatusCode) - slog.Error(msg) - return output, message, fmt.Errorf("error connecting to %s", url) - } - // Unmarshal the JSON to the Github Release strcut - if err := json.NewDecoder(resp.Body).Decode(&release); err != nil { - slog.Error("Error decoding JSON", "msg", err) - return output, message, err - } - - cVersion, err := version.NewVersion(currentVersion) - if err != nil { - slog.Error("Error creating current version", "msg", err) - return output, message, err - } - - latestVersion, err := version.NewVersion(release.TagName[1:]) - if err != nil { - slog.Error("Error creating new version", "msg", err) - return output, message, err - } - - switch cVersion.Compare(latestVersion) { - case -1: - message = fmt.Sprintf("There is a new release available: %s \n Download it here - %s", release.TagName, release.HTMLURL) - output = true - case 0: - message = "No new version available" - output = true - case 1: - message = "You are running a pre-release version" - output = true - default: - return output, message, fmt.Errorf("error comparing versions") - } - } else { - return output, message, fmt.Errorf("error connecting to %s", url) - } - - return output, message, err -} - -type release struct { - URL string `json:"url"` - AssetsURL string `json:"assets_url"` - UploadURL string `json:"upload_url"` - HTMLURL string `json:"html_url"` - ID int `json:"id"` - NodeID string `json:"node_id"` - TagName string `json:"tag_name"` - TargetCommitish string `json:"target_commitish"` - Name string `json:"name"` - Draft bool `json:"draft"` - Author author `json:"author"` - Prerelease bool `json:"prerelease"` - CreatedAt time.Time `json:"created_at"` - PublishedAt time.Time `json:"published_at"` - Assets []assets `json:"assets"` - TarballURL string `json:"tarball_url"` - ZipballURL string `json:"zipball_url"` - Body string `json:"body"` -} - -type author struct { - Login string `json:"login"` - ID int `json:"id"` - NodeID string `json:"node_id"` - AvatarURL string `json:"avatar_url"` - GravatarID string `json:"gravatar_id"` - URL string `json:"url"` - HTMLURL string `json:"html_url"` - FollowersURL string `json:"followers_url"` - FollowingURL string `json:"following_url"` - GistsURL string `json:"gists_url"` - StarredURL string `json:"starred_url"` - SubscriptionsURL string `json:"subscriptions_url"` - OrganizationsURL string `json:"organizations_url"` - ReposURL string `json:"repos_url"` - EventsURL string `json:"events_url"` - ReceivedEventsURL string `json:"received_events_url"` - Type string `json:"type"` - SiteAdmin bool `json:"site_admin"` -} -type uploader struct { - Login string `json:"login"` - ID int `json:"id"` - NodeID string `json:"node_id"` - AvatarURL string `json:"avatar_url"` - GravatarID string `json:"gravatar_id"` - URL string `json:"url"` - HTMLURL string `json:"html_url"` - FollowersURL string `json:"followers_url"` - FollowingURL string `json:"following_url"` - GistsURL string `json:"gists_url"` - StarredURL string `json:"starred_url"` - SubscriptionsURL string `json:"subscriptions_url"` - OrganizationsURL string `json:"organizations_url"` - ReposURL string `json:"repos_url"` - EventsURL string `json:"events_url"` - ReceivedEventsURL string `json:"received_events_url"` - Type string `json:"type"` - SiteAdmin bool `json:"site_admin"` -} -type assets struct { - URL string `json:"url"` - ID int `json:"id"` - NodeID string `json:"node_id"` - Name string `json:"name"` - Label string `json:"label"` - Uploader uploader `json:"uploader"` - ContentType string `json:"content_type"` - State string `json:"state"` - Size int `json:"size"` - DownloadCount int `json:"download_count"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` - BrowserDownloadURL string `json:"browser_download_url"` -} diff --git a/cmd/version_test.go b/cmd/version_test.go deleted file mode 100644 index 0025548..0000000 --- a/cmd/version_test.go +++ /dev/null @@ -1,374 +0,0 @@ -// Copyright (c) karl-cardenas-coding -// SPDX-License-Identifier: MIT - -package cmd - -import ( - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/karl-cardenas-coding/mywhoop/internal" -) - -const ( - noVersionAvailable = "No new version available" - youAreRunningAPreReleaseVersion = "You are running a pre-release version" -) - -func TestCheckForNewRelease(t *testing.T) { - - t.Skip("Skipping while in private repo") - - client := internal.CreateHTTPClient() - version := "0.0.0" - useragent := fmt.Sprintf("go-lambda-cleanup/%s", version) - - want := true - got, msg, err := checkForNewRelease(client, version, useragent, url) - if err != nil { - t.Fatalf("Error checking for new release: %s", err) - } - if got != want && msg == noVersionAvailable || msg == youAreRunningAPreReleaseVersion { - t.Fatalf("Error checking for new release: %s", err) - } - - version = "100.0.0" - want2 := true - got2, msg2, err := checkForNewRelease(client, version, useragent, url) - if err != nil { - t.Fatalf("Error checking for new release: %s", err) - } - if got2 != want2 && msg2 != youAreRunningAPreReleaseVersion { - t.Fatalf("Error checking for new release: %s", err) - } -} - -func TestErrorPath(t *testing.T) { - - t.Skip("Skipping while in private repo") - - mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - http.Error(w, "Mock error response", http.StatusInternalServerError) - })) - defer mockServer.Close() - - // Override the base URL to use the mock server URL - baseURL := mockServer.URL - - client := internal.CreateHTTPClient() - version := "------" - useragent := fmt.Sprintf("go-lambda-cleanup/%s", version) - - _, _, err := checkForNewRelease(client, version, useragent, baseURL) - if err == nil { - t.Fatalf("Error Expected: %s", err) - } -} - -func TestErrorPathJSON(t *testing.T) { - - t.Skip("Skipping while in private repo") - - mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - _, err := w.Write([]byte("invalid-json-payload")) - if err != nil { - t.Fatalf("Error writing to response writer: %s", err) - } - })) - defer mockServer.Close() - - // Override the base URL to use the mock server URL - baseURL := mockServer.URL - - client := internal.CreateHTTPClient() - version := "------" - useragent := fmt.Sprintf("go-lambda-cleanup/%s", version) - - _, _, err := checkForNewRelease(client, version, useragent, baseURL) - if err == nil { - t.Fatalf("Error Expected: %s", err) - } -} - -func TestErrorURL(t *testing.T) { - - t.Skip("Skipping while in private repo") - - client := internal.CreateHTTPClient() - version := "------" - useragent := fmt.Sprintf("go-lambda-cleanup/%s", version) - - got, want, err := checkForNewRelease(client, version, useragent, "http://localhost:1234") - if err == nil { - t.Fatalf("Error Expected: %s", err) - } - if got != false && want != IssueMSG { - t.Fatalf("Error Expected: %s", want) - } -} - -func TestCheckForNewReleaseNoNewRelease(t *testing.T) { - - t.Skip("Skipping while in private repo") - - var payload = []byte(`{ - "url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/127949448", - "assets_url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/127949448/assets", - "upload_url": "https://uploads.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/127949448/assets{?name,label}", - "html_url": "https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/tag/v2.0.10", - "id": 127949448, - "author": { - "login": "github-actions[bot]", - "id": 41898282, - "node_id": "MDM6Qm90NDE4OTgyODI=", - "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-actions%5Bbot%5D", - "html_url": "https://github.com/apps/github-actions", - "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", - "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", - "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", - "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", - "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", - "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", - "type": "Bot", - "site_admin": false - }, - "node_id": "RE_kwDOFGhZlc4HoFqI", - "tag_name": "v2.0.10", - "target_commitish": "main", - "name": "v2.0.10", - "draft": false, - "prerelease": false, - "created_at": "2023-11-03T22:18:26Z", - "published_at": "2023-11-03T22:18:37Z", - "assets": [ - { - "url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/assets/133848132", - "id": 133848132, - "node_id": "RA_kwDOFGhZlc4H-lxE", - "name": "go-lambda-cleanup-v2.0.10-darwin-amd64.zip", - "label": "", - "uploader": { - "login": "github-actions[bot]", - "id": 41898282, - "node_id": "MDM6Qm90NDE4OTgyODI=", - "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-actions%5Bbot%5D", - "html_url": "https://github.com/apps/github-actions", - "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", - "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", - "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", - "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", - "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", - "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", - "type": "Bot", - "site_admin": false - }, - "content_type": "application/zip", - "state": "uploaded", - "size": 8622699, - "download_count": 1, - "created_at": "2023-11-03T22:18:34Z", - "updated_at": "2023-11-03T22:18:35Z", - "browser_download_url": "https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/download/v2.0.10/go-lambda-cleanup-v2.0.10-darwin-amd64.zip" - }, - { - "url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/assets/133848129", - "id": 133848129, - "node_id": "RA_kwDOFGhZlc4H-lxB", - "name": "go-lambda-cleanup-v2.0.10-darwin-arm64.zip", - "label": "", - "uploader": { - "login": "github-actions[bot]", - "id": 41898282, - "node_id": "MDM6Qm90NDE4OTgyODI=", - "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-actions%5Bbot%5D", - "html_url": "https://github.com/apps/github-actions", - "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", - "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", - "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", - "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", - "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", - "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", - "type": "Bot", - "site_admin": false - }, - "content_type": "application/zip", - "state": "uploaded", - "size": 8269741, - "download_count": 2, - "created_at": "2023-11-03T22:18:33Z", - "updated_at": "2023-11-03T22:18:34Z", - "browser_download_url": "https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/download/v2.0.10/go-lambda-cleanup-v2.0.10-darwin-arm64.zip" - }, - { - "url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/assets/133848128", - "id": 133848128, - "node_id": "RA_kwDOFGhZlc4H-lxA", - "name": "go-lambda-cleanup-v2.0.10-linux-386.zip", - "label": "", - "uploader": { - "login": "github-actions[bot]", - "id": 41898282, - "node_id": "MDM6Qm90NDE4OTgyODI=", - "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-actions%5Bbot%5D", - "html_url": "https://github.com/apps/github-actions", - "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", - "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", - "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", - "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", - "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", - "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", - "type": "Bot", - "site_admin": false - }, - "content_type": "application/zip", - "state": "uploaded", - "size": 8169046, - "download_count": 2, - "created_at": "2023-11-03T22:18:32Z", - "updated_at": "2023-11-03T22:18:33Z", - "browser_download_url": "https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/download/v2.0.10/go-lambda-cleanup-v2.0.10-linux-386.zip" - }, - { - "url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/assets/133848138", - "id": 133848138, - "node_id": "RA_kwDOFGhZlc4H-lxK", - "name": "go-lambda-cleanup-v2.0.10-linux-amd64.zip", - "label": "", - "uploader": { - "login": "github-actions[bot]", - "id": 41898282, - "node_id": "MDM6Qm90NDE4OTgyODI=", - "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-actions%5Bbot%5D", - "html_url": "https://github.com/apps/github-actions", - "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", - "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", - "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", - "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", - "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", - "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", - "type": "Bot", - "site_admin": false - }, - "content_type": "application/zip", - "state": "uploaded", - "size": 8631978, - "download_count": 15, - "created_at": "2023-11-03T22:18:35Z", - "updated_at": "2023-11-03T22:18:36Z", - "browser_download_url": "https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/download/v2.0.10/go-lambda-cleanup-v2.0.10-linux-amd64.zip" - }, - { - "url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/releases/assets/133848139", - "id": 133848139, - "node_id": "RA_kwDOFGhZlc4H-lxL", - "name": "go-lambda-cleanup-v2.0.10-windows-amd64.zip", - "label": "", - "uploader": { - "login": "github-actions[bot]", - "id": 41898282, - "node_id": "MDM6Qm90NDE4OTgyODI=", - "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4", - "gravatar_id": "", - "url": "https://api.github.com/users/github-actions%5Bbot%5D", - "html_url": "https://github.com/apps/github-actions", - "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers", - "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}", - "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}", - "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions", - "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs", - "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos", - "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}", - "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events", - "type": "Bot", - "site_admin": false - }, - "content_type": "application/zip", - "state": "uploaded", - "size": 8759318, - "download_count": 1, - "created_at": "2023-11-03T22:18:36Z", - "updated_at": "2023-11-03T22:18:37Z", - "browser_download_url": "https://github.com/karl-cardenas-coding/go-lambda-cleanup/releases/download/v2.0.10/go-lambda-cleanup-v2.0.10-windows-amd64.zip" - } - ], - "tarball_url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/tarball/v2.0.10", - "zipball_url": "https://api.github.com/repos/karl-cardenas-coding/go-lambda-cleanup/zipball/v2.0.10", - "body": "## [2.0.10](https://github.com/karl-cardenas-coding/go-lambda-cleanup/compare/v2.0.9...v2.0.10) (2023-11-03)\n\n\n### Bug Fixes\n\n* updated dependencies ([778b9e2](https://github.com/karl-cardenas-coding/go-lambda-cleanup/commit/778b9e2a457544c1874582abdca089d2123578a1))\n\n\n\n" - }`) - - mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json") - - // Write an invalid JSON payload to the response writer - _, err := w.Write(payload) - if err != nil { - t.Fatalf("Error writing to response writer: %s", err) - } - })) - defer mockServer.Close() - - // Override the base URL to use the mock server URL - baseURL := mockServer.URL - - client := internal.CreateHTTPClient() - version := "2.0.10" - useragent := fmt.Sprintf("go-lambda-cleanup/%s", version) - - want := false - got, msg, err := checkForNewRelease(client, version, useragent, baseURL) - if err != nil { - t.Fatalf("Error encountered: %s", err) - } - - if got != want && msg != noVersionAvailable { - t.Fatalf("Error checking for new release: %s", msg) - } -} - -func TestVersionCMD(t *testing.T) { - - t.Skip("Skipping while in private repo") - - VersionString = "1.0.0" - - err := VersionCmd.RunE(VersionCmd, []string{}) - if err != nil { - t.Errorf("expected no error to be returned but received %v", err) - } - - VersionString = "aaaa" - err = VersionCmd.RunE(VersionCmd, []string{}) - if err == nil { - t.Errorf("expected an error to be returned but received %v", err) - } - -}