This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 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
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 |
---|---|---|
@@ -1,7 +1,22 @@ | ||
package qiwi | ||
|
||
import "fmt" | ||
|
||
// AppVersion for version string of main application version | ||
var AppVersion string | ||
|
||
const ( | ||
// Version string. | ||
Version string = "0.3" | ||
Version string = "1.0.0" | ||
userAgent string = "Sendtips-QIWI-Go" // UserAgent name | ||
) | ||
|
||
func version() (s string) { | ||
s = fmt.Sprintf("%s/%s", userAgent, Version) | ||
|
||
if AppVersion != "" { | ||
s = fmt.Sprintf("%s (%s)", AppVersion, s) | ||
} | ||
|
||
return s | ||
} |
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,22 @@ | ||
package qiwi | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestVersion(t *testing.T) { | ||
s := fmt.Sprintf("%s/%s", userAgent, Version) | ||
|
||
if s != version() { | ||
t.Error("Version string is invalid") | ||
} | ||
|
||
AppVersion = "somever/1.0" | ||
s = fmt.Sprintf("%s (%s/%s)", AppVersion, userAgent, Version) | ||
|
||
if s != version() { | ||
t.Error("Version string is invalid") | ||
} | ||
|
||
} |