-
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
6 changed files
with
230 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: test | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.20' | ||
- name: Test | ||
run: go test -v ./pkg/... |
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,113 @@ | ||
project_name: amtui | ||
release: | ||
github: | ||
owner: pehlicd | ||
name: amtui | ||
name_template: '{{.Tag}}' | ||
builds: | ||
- id: amtui | ||
goos: | ||
- linux | ||
- darwin | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
goarm: | ||
- "6" | ||
gomips: | ||
- hardfloat | ||
goamd64: | ||
- v1 | ||
targets: | ||
- linux_amd64_v1 | ||
- linux_arm64 | ||
- darwin_amd64_v1 | ||
- darwin_arm64 | ||
- windows_amd64_v1 | ||
ignore: | ||
- goos: windows | ||
goarch: arm64 | ||
dir: . | ||
main: . | ||
binary: amtui | ||
builder: go | ||
gobinary: go | ||
command: build | ||
ldflags: | ||
- -s -w -X pkg.versionString={{ .Tag } | ||
env: | ||
- CGO_ENABLED=0 | ||
archives: | ||
- id: default | ||
builds: | ||
- amtui | ||
name_template: '{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}' | ||
format: tar.gz | ||
wrap_in_directory: "false" | ||
files: | ||
- src: LICENSE | ||
snapshot: | ||
name_template: '{{ .Version }}-SNAPSHOT-{{ .ShortCommit }}' | ||
checksum: | ||
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' | ||
algorithm: sha256 | ||
dist: dist | ||
env_files: | ||
github_token: ~/.config/goreleaser/github_token | ||
gitlab_token: ~/.config/goreleaser/gitlab_token | ||
gitea_token: ~/.config/goreleaser/gitea_token | ||
before: | ||
hooks: | ||
- go mod download | ||
source: | ||
name_template: '{{ .ProjectName }}-{{ .Version }}' | ||
format: tar.gz | ||
gomod: | ||
gobinary: go | ||
announce: | ||
twitter: | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
mastodon: | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
server: "" | ||
reddit: | ||
title_template: '{{ .ProjectName }} {{ .Tag }} is out!' | ||
url_template: '{{ .ReleaseURL }}' | ||
slack: | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
username: GoReleaser | ||
discord: | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
author: GoReleaser | ||
color: "3888754" | ||
icon_url: https://goreleaser.com/static/avatar.png | ||
teams: | ||
title_template: '{{ .ProjectName }} {{ .Tag }} is out!' | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
color: '#2D313E' | ||
icon_url: https://goreleaser.com/static/avatar.png | ||
smtp: | ||
subject_template: '{{ .ProjectName }} {{ .Tag }} is out!' | ||
body_template: 'You can view details from: {{ .ReleaseURL }}' | ||
mattermost: | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
title_template: '{{ .ProjectName }} {{ .Tag }} is out!' | ||
username: GoReleaser | ||
linkedin: | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}' | ||
telegram: | ||
message_template: '{{ .ProjectName }} {{ mdv2escape .Tag }} is out! Check it out at {{ mdv2escape .ReleaseURL }}' | ||
parse_mode: MarkdownV2 | ||
webhook: | ||
message_template: '{ "message": "{{ .ProjectName }} {{ .Tag }} is out! Check it out at {{ .ReleaseURL }}"}' | ||
content_type: application/json; charset=utf-8 | ||
opencollective: | ||
title_template: '{{ .Tag }}' | ||
message_template: '{{ .ProjectName }} {{ .Tag }} is out!<br/>Check it out at <a href="{{ .ReleaseURL }}">{{ .ReleaseURL }}</a>' | ||
git: | ||
tag_sort: -version:refname | ||
github_urls: | ||
download: https://github.com | ||
gitlab_urls: | ||
download: https://gitlab.com |
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,35 @@ | ||
package pkg | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestInitConfigDefault(t *testing.T) { | ||
// Test case 1: Test with default values | ||
os.Args = []string{"amtui"} | ||
config := initConfig() | ||
assert.Equal(t, "localhost", config.Host) | ||
assert.Equal(t, "9093", config.Port) | ||
assert.Equal(t, true, config.Insecure) | ||
assert.Equal(t, "http", config.Scheme) | ||
} | ||
|
||
func TestInitConfigCustom(t *testing.T) { | ||
// Test case 2: Test with custom values | ||
os.Args = []string{"amtui", "--host", "example.com", "--port", "9090", "--insecure=false"} | ||
config := initConfig() | ||
config = initConfig() | ||
assert.Equal(t, "example.com", config.Host) | ||
assert.Equal(t, "9090", config.Port) | ||
assert.Equal(t, false, config.Insecure) | ||
assert.Equal(t, "https", config.Scheme) | ||
} | ||
|
||
func TestInitInvalid(t *testing.T) { | ||
// Test case 3: Test with invalid flags | ||
os.Args = []string{"amtui", "--invalid-flag"} | ||
assert.Panics(t, func() { printHelp(os.Stderr) }) | ||
} |