Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
triole committed Jun 23, 2024
1 parent 4d50276 commit 0ddd6d5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}
Expand All @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion testdata/bats/no_ext

This file was deleted.

52 changes: 52 additions & 0 deletions testdata/yaml/conf.yaml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 0ddd6d5

Please sign in to comment.