Skip to content

Commit

Permalink
test: add gen vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
shiron-dev committed Dec 18, 2024
1 parent 2ebad35 commit 1165680
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ gen:
.PHONY: release
release:
@goreleaser release --snapshot --clean

.PHONY: test
test:
@go test -v ./...
3 changes: 3 additions & 0 deletions cmd/gen/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package gen

var VSCodeCmd = vscodeCmd
11 changes: 11 additions & 0 deletions cmd/gen/init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package gen_test

import (
"os"
"testing"
)

func TestMain(m *testing.M) {
code := m.Run()
os.Exit(code)
}
62 changes: 62 additions & 0 deletions cmd/gen/vscode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package gen_test

import (
"io"
"os"
"path"
"testing"

"github.com/shiron-dev/arcanum-hue/cmd/gen"
)

var originalArgs = os.Args

func setArgs(arg string) {
//nolint:gocritic
os.Args = append(originalArgs, arg)
}

func resetArgs() {
os.Args = originalArgs
}

func Test_vscodeCmd(t *testing.T) {
t.Parallel()

setArgs("sub")

defer resetArgs()

tempDir := t.TempDir()

configFilePath := path.Join(tempDir, "config.yaml")

cwDir, err := os.Getwd()
if err != nil {
t.Fatal(err)
}

testConfig, err := os.Open(path.Join(cwDir, "../../data/config.yaml"))
if err != nil {
t.Fatal(err)
}
defer testConfig.Close()

configFile, err := os.Create(configFilePath)
if err != nil {
t.Fatal(err)
}
defer configFile.Close()

_, err = io.Copy(configFile, testConfig)
if err != nil {
t.Fatal(err)
}

err = os.WriteFile(configFilePath, []byte("name: test"), 0o600)
if err != nil {
t.Fatal(err)
}

gen.VSCodeCmd.Run(gen.VSCodeCmd, []string{configFilePath, tempDir})
}
40 changes: 40 additions & 0 deletions data/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# yaml-language-server: $schema=../schema.json
name: Test Config
description: This is a test config file
colorThemes:
- name: Dark
vscodeUiTheme: vs-dark
type: dark
colors:
foreground: "#CCCCCC"
hiForeground: "#F8F8F8"
secondaryForeground: "#6E7681"
foregroundAccent: "#4daafc"
warningForeground: "#F85149"

background: "#181818"
editorBackground: "#1F1F1F"
secondaryBackground: "#313131"
backgroundAccent: "#026EC1"
hiBackgroundAccent: "#026EC1"
matchBackground: "#9E6A03"

border: "#2B2B2B"

terminalAnsi:
black: "#"
brightBlack: "#"
blue: "#"
cyan: "#"
green: "#"
brightBlue: "#"
brightCyan: "#"
brightGreen: "#"
white: "#"
brightWhite: "#"
magenta: "#"
yellow: "#"
red: "#"
brightYellow: "#"
brightMagenta: "#"
brightRed: "#"

0 comments on commit 1165680

Please sign in to comment.