Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit test for sensors.TemperaturesWithContext #1725

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions sensors/sensors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package sensors

import (
"context"

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / lint

"context" imported and not used (typecheck)

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-22.04)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-24.04)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-20.04)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-22.04)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.22.8)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-20.04)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-14)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.23.2)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-13)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-24.04)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-13)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2022)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-14)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-12)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-12)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2022)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2019)

"context" imported and not used

Check failure on line 6 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2019)

"context" imported and not used
"fmt"
"testing"
)
Expand All @@ -19,3 +20,25 @@
t.Errorf("TemperatureStat string is invalid, %v", fmt.Sprintf("%v", v))
}
}

func skipIfNotImplementedErr(t *testing.T, err error) {
if errors.Is(err, common.ErrNotImplementedError) {

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: errors (typecheck)

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-22.04)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-22.04)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-24.04)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-24.04)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-20.04)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-20.04)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-22.04)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-22.04)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.22.8)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.22.8)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-20.04)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-20.04)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-14)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-14)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.23.2)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.23.2)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-13)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-13)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-24.04)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-24.04)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-13)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-13)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2022)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2022)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-14)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-14)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-12)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-12)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-12)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-12)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2022)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2022)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2019)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2019)

undefined: common

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2019)

undefined: errors

Check failure on line 25 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2019)

undefined: common
t.Skip("not implemented")
}
}

func TestTemperatures(t *testing.T) {
if os.Getenv("CI") != "" {

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: os (typecheck)

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-22.04)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-24.04)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-20.04)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, ubuntu-22.04)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.22.8)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-20.04)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-14)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / build_test (1.23.2)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-13)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, ubuntu-24.04)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-13)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2022)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-14)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, macos-12)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, macos-12)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2022)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.22.8, windows-2019)

undefined: os

Check failure on line 31 in sensors/sensors_test.go

View workflow job for this annotation

GitHub Actions / test (1.23.2, windows-2019)

undefined: os
t.Skip("Skip CI")
}

v, err := SensorsTemperatures()
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}
if len(v) == 0 {
t.Errorf("Could not get temperature %v", v)
}
t.Log(v)
}
Loading