Documentation ¶
Overview ¶
Package eventlog_test provides helpers for testing code that uses the eventlog package
Index ¶
- Constants
- func GetEnabledAPITesters() []string
- type APITester
- type FakeAPITester
- func (ti *FakeAPITester) API() evtapi.API
- func (ti *FakeAPITester) GenerateEvents(channelName string, numEvents uint) error
- func (ti *FakeAPITester) InstallChannel(channel string) error
- func (ti *FakeAPITester) InstallSource(channel string, source string) error
- func (ti *FakeAPITester) KillEventLogService(t *testing.T)
- func (ti *FakeAPITester) Name() string
- func (ti *FakeAPITester) RemoveChannel(channel string) error
- func (ti *FakeAPITester) RemoveSource(channel string, source string) error
- func (ti *FakeAPITester) StartEventLogService(t *testing.T)
- type WindowsAPITester
- func (ti *WindowsAPITester) API() evtapi.API
- func (ti *WindowsAPITester) GenerateEvents(channelName string, numEvents uint) error
- func (ti *WindowsAPITester) InstallChannel(channel string) error
- func (ti *WindowsAPITester) InstallSource(channel string, source string) error
- func (ti *WindowsAPITester) KillEventLogService(t *testing.T)
- func (ti *WindowsAPITester) Name() string
- func (ti *WindowsAPITester) RemoveChannel(channel string) error
- func (ti *WindowsAPITester) RemoveSource(channel string, source string) error
- func (ti *WindowsAPITester) StartEventLogService(t *testing.T)
Constants ¶
const (
// FakeAPIName identifies this API in GetAPITesterByName
FakeAPIName = "Fake"
)
const (
// WindowsAPIName identifies this API in GetAPITesterByName
WindowsAPIName = "Windows"
)
Variables ¶
This section is empty.
Functions ¶
func GetEnabledAPITesters ¶
func GetEnabledAPITesters() []string
GetEnabledAPITesters returns the APIs that are available to test as specified by enabledAPIsFlag
Types ¶
type APITester ¶
type APITester interface { Name() string API() evtapi.API InstallChannel(channel string) error RemoveChannel(channel string) error InstallSource(channel string, source string) error RemoveSource(channel string, name string) error GenerateEvents(channelName string, numEvents uint) error StartEventLogService(t *testing.T) KillEventLogService(t *testing.T) }
APITester defines the interface used to test Windows Event Log API implementations. Notably it has helpers for adding/removing event logs and sources which would normally be the work of an installer.
type FakeAPITester ¶
type FakeAPITester struct {
// contains filtered or unexported fields
}
FakeAPITester uses a limited in-memory re-implementation of the Windows EventLog APIs and provides utilities to the test framework that will simulate behavior and not make any changes to the host system
func NewFakeAPITester ¶
func NewFakeAPITester() *FakeAPITester
NewFakeAPITester constructs a new API tester for a fake Windows Event Log API
func (*FakeAPITester) GenerateEvents ¶
func (ti *FakeAPITester) GenerateEvents(channelName string, numEvents uint) error
GenerateEvents creates numEvents new event records
func (*FakeAPITester) InstallChannel ¶
func (ti *FakeAPITester) InstallChannel(channel string) error
InstallChannel adds a new event log
func (*FakeAPITester) InstallSource ¶
func (ti *FakeAPITester) InstallSource(channel string, source string) error
InstallSource adds a new source to an event log channel
func (*FakeAPITester) KillEventLogService ¶ added in v0.51.1
func (ti *FakeAPITester) KillEventLogService( t *testing.T, )
KillEventLogService is TODO for the fake API
func (*FakeAPITester) Name ¶
func (ti *FakeAPITester) Name() string
Name returns the name that identifies this tester for use by GetAPITesterByName
func (*FakeAPITester) RemoveChannel ¶
func (ti *FakeAPITester) RemoveChannel(channel string) error
RemoveChannel removes an event log
func (*FakeAPITester) RemoveSource ¶
func (ti *FakeAPITester) RemoveSource(channel string, source string) error
RemoveSource removes a source from an event log channel
func (*FakeAPITester) StartEventLogService ¶ added in v0.51.1
func (ti *FakeAPITester) StartEventLogService( t *testing.T, )
StartEventLogService is TODO for the fake API
type WindowsAPITester ¶
type WindowsAPITester struct {
// contains filtered or unexported fields
}
WindowsAPITester uses the real Windows EventLog APIs and provides utilities to the test framework that will modify the host system (e.g. install event log source, generate events).
func NewWindowsAPITester ¶
func NewWindowsAPITester() *WindowsAPITester
NewWindowsAPITester constructs a new API tester for the Windows Event Log API
func (*WindowsAPITester) API ¶
func (ti *WindowsAPITester) API() evtapi.API
API returns the Windows API
func (*WindowsAPITester) GenerateEvents ¶
func (ti *WindowsAPITester) GenerateEvents(channelName string, numEvents uint) error
GenerateEvents creates numEvents new event records
func (*WindowsAPITester) InstallChannel ¶
func (ti *WindowsAPITester) InstallChannel(channel string) error
InstallChannel adds a new event log. New event logs are created by creating registry keys.
func (*WindowsAPITester) InstallSource ¶
func (ti *WindowsAPITester) InstallSource(channel string, source string) error
InstallSource adds a new source to an event log. New sources are created by creating registry keys. eventcreate.exe is used for the EventMessageFile because it has a generic message format that enables EvtFormatMessage to succeed
func (*WindowsAPITester) KillEventLogService ¶ added in v0.51.1
func (ti *WindowsAPITester) KillEventLogService(t *testing.T)
KillEventLogService stops the Windows Event Log service and adds a Cleanup task to the test to restart it at the end of the test.
func (*WindowsAPITester) Name ¶
func (ti *WindowsAPITester) Name() string
Name returns the name that identifies this tester for use by GetAPITesterByName
func (*WindowsAPITester) RemoveChannel ¶
func (ti *WindowsAPITester) RemoveChannel(channel string) error
RemoveChannel removes an event log. Event logs are removed by deleting registry keys.
func (*WindowsAPITester) RemoveSource ¶
func (ti *WindowsAPITester) RemoveSource(channel string, source string) error
RemoveSource removes a source from an event log channel. Sources are removed by deleting registry keys.
func (*WindowsAPITester) StartEventLogService ¶ added in v0.51.1
func (ti *WindowsAPITester) StartEventLogService(t *testing.T)
StartEventLogService starts the Windows Event Log service