From 0ddd6d5a606e9704e75bc8126ec6bad01192e287 Mon Sep 17 00:00:00 2001 From: olaf michaelis Date: Sun, 23 Jun 2024 17:48:42 +0200 Subject: [PATCH] Fix tests --- src/detect_test.go | 8 +++---- testdata/bats/no_ext | 1 - testdata/yaml/conf.yaml | 52 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 5 deletions(-) delete mode 100644 testdata/bats/no_ext create mode 100644 testdata/yaml/conf.yaml diff --git a/src/detect_test.go b/src/detect_test.go index 39dfe77..461f14f 100644 --- a/src/detect_test.go +++ b/src/detect_test.go @@ -15,11 +15,11 @@ func TestDetect(t *testing.T) { expectedName := find(`[^/]+/[^/]+$`, filename) expectedName = find(`^.*?/`, expectedName) expectedName = expectedName[0 : len(expectedName)-1] - coda := initCoda("../conf/coda.toml", filename) + coda := initCoda("../testdata/yaml/conf.yaml", filename) ft := coda.detect() if expectedName != ft.Name { t.Errorf( - "Assertion detect failed: %q, %q != %q", + "assertion detect failed: %q, %q != %q", filename, expectedName, ft.Name, ) } @@ -29,13 +29,13 @@ func TestDetect(t *testing.T) { func getFiles(p string) (files []string) { root, err := filepath.Abs(p) if err != nil { - fmt.Printf("Can not make absolute file path: %s\n", err) + fmt.Printf("can not make absolute file path: %s\n", err) os.Exit(1) } err = filepath.Walk(root, func(path string, info os.FileInfo, err error) error { if err != nil { - fmt.Printf("Can not walk over files: %s\n", err) + fmt.Printf("can not walk over files: %s\n", err) return nil } diff --git a/testdata/bats/no_ext b/testdata/bats/no_ext deleted file mode 100644 index 4d965f0..0000000 --- a/testdata/bats/no_ext +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/env bats diff --git a/testdata/yaml/conf.yaml b/testdata/yaml/conf.yaml new file mode 100644 index 0000000..aac772a --- /dev/null +++ b/testdata/yaml/conf.yaml @@ -0,0 +1,52 @@ +--- +filetypes: + - name: bash + regex: ".*\\.sh$" + shebang: "#!/bin/bash" + cmds: + - ["shellcheck", "-x", "-e", "SC1090,SC2154,SC2155", "{{.filename}}"] + - ["shfmt", "-w", "-ci", "-i", "2", "{{.filename}}"] + + - name: caddyfile + regex: ".*\\.?(C|c)addyfile$" + cmds: + - ["caddy", "fmt", "--overwrite", "{{.filename}}"] + + - name: golang + regex: ".*\\.go$" + cmds: + - ["goimports", "-w", "{{.filename}}"] + - ["gofmt", "-w", "{{.filename}}"] + - ["staticcheck", "{{.filename}}"] + - ["go", "test", "-v"] + + - name: python + regex: ".*\\.py$" + shebang: "#!/usr/bin/python3" + cmds: + - ["autoflake", "--remove-all-unused-imports", "-i", "{{.filename}}"] + - ["isort", "{{.filename}}"] + - ["black", "{{.filename}}"] + + - name: rust + regex: ".*\\.rs$" + cmds: + - ["rustfmt", "{{.filename}}"] + - ["cargo", "test", "--color", "always"] + + - name: yaml + regex: ".*\\.(yml|yaml)$" + cmds: + - ["keep-sorted", "{{.filename}}"] + - ["yamlfmt", "-conf", "${HOME}/tools/shed/yamlfmt.yaml", + "{{.filename}}"] + +settings: + ignore_list: + - ".git/" + - ".pytest" + - "__pycache__" + - "/target/debug/" + - "/target/release/" + - ".lock$" + - ".rs.racertmp"