Skip to content

Commit f7697f9

Browse files
authored
Unit test (#71)
* feat - add unit test * fix - disable analytics for tests * feat - tests on workflows * FIX - auth token * FIX - auth token * FIX - workflow * FIX - add testing cases * FIX - testing cases * FIX - add testing cases
1 parent 276cf1a commit f7697f9

14 files changed

Lines changed: 333 additions & 22 deletions

File tree

.github/workflows/pr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ jobs:
2929

3030
- run: go mod vendor
3131

32+
- name: Test
33+
run: go test -v
34+
env:
35+
VERSION: ${{ env.GITHUB_REF_NAME }}
36+
TOKEN: ${{ secrets.AAI_TEST_TOKEN }}
37+
3238
- name: install GoReleaser
3339
uses: goreleaser/goreleaser-action@v3
3440
with:

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030

3131
- run: go mod vendor
3232

33+
- name: Test
34+
run: go test -v
35+
env:
36+
VERSION: ${{ env.GITHUB_REF_NAME }}
37+
TOKEN: ${{ secrets.AAI_TEST_TOKEN }}
38+
3339
- name: Run GoReleaser
3440
uses: goreleaser/goreleaser-action@v3
3541
with:

cmd/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@ var configCmd = &cobra.Command{
5151
}
5252

5353
func init() {
54+
configCmd.Flags().Bool("test", false, "Flag for test executing purpose")
55+
configCmd.Flags().MarkHidden("test")
56+
5457
rootCmd.AddCommand(configCmd)
5558
}

cmd/get.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,6 @@ func init() {
5050
rootCmd.AddCommand(getCmd)
5151
getCmd.Flags().BoolP("json", "j", false, "If true, the CLI will output the JSON.")
5252
getCmd.Flags().BoolP("poll", "p", true, "The CLI will poll the transcription until it's complete.")
53+
getCmd.Flags().Bool("test", false, "Flag for test executing purpose")
54+
getCmd.Flags().MarkHidden("test")
5355
}

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ func Execute() {
5151

5252
func init() {
5353
rootCmd.PersistentFlags().BoolP("version", "v", false, "Check current installed version.")
54+
rootCmd.Flags().Bool("test", false, "Flag for test executing purpose")
55+
rootCmd.Flags().MarkHidden("test")
5456
}

cmd/transcribe.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ var transcribeCmd = &cobra.Command{
5353
params.TopicDetection, _ = cmd.Flags().GetBool("topic_detection")
5454
params.Summarization, _ = cmd.Flags().GetBool("summarization")
5555
wordBoost, _ := cmd.Flags().GetString("word_boost")
56+
if params.DualChannel && params.SpeakerLabels {
57+
if cmd.Flags().Lookup("speaker_labels").Changed {
58+
printErrorProps := S.PrintErrorProps{
59+
Error: errors.New("Speaker labels are not supported for dual channel audio"),
60+
Message: "Speaker labels are not supported for dual channel audio",
61+
}
62+
U.PrintError(printErrorProps)
63+
return
64+
}
65+
params.SpeakerLabels = false
66+
}
5667
if wordBoost != "" {
5768
params.WordBoost = strings.Split(wordBoost, ",")
5869
boostParam, _ := cmd.Flags().GetString("boost_param")
@@ -70,6 +81,15 @@ var transcribeCmd = &cobra.Command{
7081
params.Punctuate = true
7182
params.FormatText = true
7283

84+
if params.AutoChapters {
85+
printErrorProps := S.PrintErrorProps{
86+
Error: errors.New("Auto chapters are not supported for summarization"),
87+
Message: "Auto chapters are not supported for summarization",
88+
}
89+
U.PrintError(printErrorProps)
90+
return
91+
}
92+
7393
params.SummaryType, _ = cmd.Flags().GetString("summary_type")
7494
if _, ok := S.SummarizationTypeMapReverse[params.SummaryType]; !ok {
7595
printErrorProps := S.PrintErrorProps{
@@ -140,6 +160,14 @@ var transcribeCmd = &cobra.Command{
140160
}
141161
languageDetection, _ := cmd.Flags().GetBool("language_detection")
142162
languageCode, _ := cmd.Flags().GetString("language_code")
163+
if languageDetection && languageCode != "" {
164+
printErrorProps := S.PrintErrorProps{
165+
Error: errors.New("Invalid language detection"),
166+
Message: "Please provide either language detection or language code, not both.",
167+
}
168+
U.PrintError(printErrorProps)
169+
return
170+
}
143171
if (languageCode != "" || languageDetection) && params.SpeakerLabels {
144172
if cmd.Flags().Lookup("speaker_labels").Changed {
145173
printErrorProps := S.PrintErrorProps{
@@ -259,5 +287,8 @@ func init() {
259287
transcribeCmd.PersistentFlags().StringP("word_boost", "k", "", "The value of this flag MUST be used surrounded by quotes. Any term included will have its likelihood of being transcribed boosted.")
260288
transcribeCmd.PersistentFlags().StringP("summary_model", "q", "informative", "The model used to generate the summary.")
261289

290+
transcribeCmd.Flags().Bool("test", false, "Flag for test executing purpose")
291+
transcribeCmd.Flags().MarkHidden("test")
292+
262293
rootCmd.AddCommand(transcribeCmd)
263294
}

cmd/validate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ var validateCmd = &cobra.Command{
2828
}
2929

3030
func init() {
31+
validateCmd.Flags().Bool("test", false, "Flag for test executing purpose")
32+
validateCmd.Flags().MarkHidden("test")
33+
3134
rootCmd.AddCommand(validateCmd)
3235
}

cmd/welcome.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,6 @@ func init() {
6363
welcomeCmd.PersistentFlags().StringP("arch", "a", "", "")
6464
welcomeCmd.PersistentFlags().StringP("method", "m", "", "")
6565
welcomeCmd.PersistentFlags().StringP("version", "v", "", "")
66+
welcomeCmd.Flags().Bool("test", false, "Flag for test executing purpose")
67+
welcomeCmd.Flags().MarkHidden("test")
6668
}

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
)
1717

1818
require (
19+
github.com/davecgh/go-spew v1.1.1 // indirect
1920
github.com/fatih/color v1.13.0 // indirect
2021
github.com/fsnotify/fsnotify v1.5.4 // indirect
2122
github.com/hashicorp/hcl v1.0.0 // indirect
@@ -27,12 +28,16 @@ require (
2728
github.com/mitchellh/mapstructure v1.5.0 // indirect
2829
github.com/pelletier/go-toml v1.9.5 // indirect
2930
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
31+
github.com/pmezard/go-difflib v1.0.0 // indirect
3032
github.com/spf13/afero v1.8.2 // indirect
3133
github.com/spf13/cast v1.5.0 // indirect
3234
github.com/spf13/jwalterweatherman v1.1.0 // indirect
3335
github.com/spf13/pflag v1.0.5 // indirect
36+
github.com/stretchr/objx v0.5.0 // indirect
37+
github.com/stretchr/testify v1.8.1 // indirect
3438
github.com/subosito/gotenv v1.4.1 // indirect
3539
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
40+
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 // indirect
3641
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
3742
golang.org/x/text v0.3.7 // indirect
3843
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,17 @@ github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU=
198198
github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw=
199199
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
200200
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
201+
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
202+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
201203
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
202204
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
203205
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
204206
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
205207
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
206208
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
207209
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
210+
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
211+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
208212
github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
209213
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
210214
github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
@@ -214,6 +218,8 @@ github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
214218
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
215219
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
216220
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
221+
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 h1:qXafrlZL1WsJW5OokjraLLRURHiw0OzKHD/RNdspp4w=
222+
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04/go.mod h1:FiwNQxz6hGoNFBC4nIx+CxZhI3nne5RmIOlT/MXcSD4=
217223
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
218224
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
219225
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=

0 commit comments

Comments
 (0)