Skip to content

Commit

Permalink
add fail_test.go to test CI
Browse files Browse the repository at this point in the history
  • Loading branch information
makramkd committed Jul 15, 2024
1 parent 246b09b commit d5673b8
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions fail_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package main

import (
"errors"
"os"
"sync"
"testing"
)

func TestFail(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Fatal("fake failure")
}

func TestRace(t *testing.T) {
var v int
var wg sync.WaitGroup
wg.Add(100)
for i := 0; i < 100; i++ {
go func() {
defer wg.Done()
v++
v--
}()
}
wg.Wait()
t.Log(v)
}

func TestLint(t *testing.T) {
const UnusedVar = 1 // lint should complain for unused variable

Check failure on line 33 in fail_test.go

View workflow job for this annotation

GitHub Actions / lint

const `UnusedVar` is unused (unused)
const ALL_CAPS = 10 // should be AllCaps

Check failure on line 34 in fail_test.go

View workflow job for this annotation

GitHub Actions / lint

const `ALL_CAPS` is unused (unused)
err := os.ErrNotExist
if err == os.ErrNotExist { // should use errors.Is

Check failure on line 36 in fail_test.go

View workflow job for this annotation

GitHub Actions / lint

comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error (errorlint)
err := errors.New("fake error") // shadowed variable
t.Log(err)
}
}

0 comments on commit d5673b8

Please sign in to comment.