Skip to content

Commit 5b5c1ae

Browse files
committed
Add test and test job
1 parent 53db908 commit 5b5c1ae

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

.github/workflows/go.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: ci
2+
3+
permissions:
4+
contents: read
5+
pull-requests: read
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches: [main, master]
11+
tags: '*'
12+
pull_request:
13+
branches: '**'
14+
merge_group:
15+
types: [checks_requested]
16+
17+
jobs:
18+
go_test:
19+
name: go test
20+
runs-on: windows-latest
21+
strategy:
22+
fail-fast: false
23+
steps:
24+
- name: Check out code
25+
id: checkout
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 1
29+
30+
- name: Setup Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version-file: './go.mod'
34+
check-latest: true
35+
cache: false
36+
37+
- id: go-cache-paths
38+
shell: bash
39+
run: |
40+
echo "go-build=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
41+
echo "go-mod=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
42+
43+
- name: cache restore - GOCACHE
44+
uses: actions/cache/restore@v4
45+
with:
46+
path: ${{ steps.go-cache-paths.outputs.go-build }}
47+
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
48+
enableCrossOsArchive: true
49+
50+
- name: cache restore - GOMODCACHE
51+
uses: actions/cache/restore@v4
52+
with:
53+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
54+
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
55+
enableCrossOsArchive: true
56+
57+
- name: Short Test
58+
shell: bash
59+
run: go test -race -cover -coverprofile=coverage.out -short -timeout 10m ./...
60+
61+
- name: Upload coverage
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: ${{ runner.os }}-coverage.out
65+
path: ./coverage.out
66+
if-no-files-found: error
67+
68+
ci_mergeable:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- run: true
72+
needs:
73+
- go_test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.exe
2+
coverage.out

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ go 1.24.0
55
toolchain go1.24.5
66

77
require golang.org/x/sys v0.36.0
8+
9+
require (
10+
github.com/davecgh/go-spew v1.1.1 // indirect
11+
github.com/pmezard/go-difflib v1.0.0 // indirect
12+
github.com/stretchr/testify v1.11.1
13+
gopkg.in/yaml.v3 v3.0.1 // indirect
14+
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
6+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
17
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
28
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
9+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
11+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
12+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

winlsa_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//go:build windows
2+
// +build windows
3+
4+
package winlsa
5+
6+
import (
7+
"testing"
8+
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func TestGetLogonSessions_GetLogonSessionData(t *testing.T) {
13+
t.Parallel()
14+
15+
luids, err := GetLogonSessions()
16+
require.NoError(t, err)
17+
18+
for _, luid := range luids {
19+
sessionData, err := GetLogonSessionData(&luid)
20+
require.NoError(t, err)
21+
require.NotNil(t, sessionData.Sid)
22+
}
23+
}

0 commit comments

Comments
 (0)