File: privileges_test.go

package info (click to toggle)
golang-github-microsoft-go-winio 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 764 kB
  • sloc: makefile: 3
file content (24 lines) | stat: -rw-r--r-- 474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//go:build windows
// +build windows

package winio

import (
	"errors"
	"testing"
)

func TestRunWithUnavailablePrivilege(t *testing.T) {
	err := RunWithPrivilege("SeCreateTokenPrivilege", func() error { return nil })
	var perr *PrivilegeError
	if !errors.As(err, &perr) {
		t.Fatal("expected PrivilegeError")
	}
}

func TestRunWithPrivileges(t *testing.T) {
	err := RunWithPrivilege("SeShutdownPrivilege", func() error { return nil })
	if err != nil {
		t.Fatal(err)
	}
}