Skip to content

Commit

Permalink
Remove runtime dependent InstallTime checks from unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Wurm committed Apr 26, 2019
1 parent a29cbee commit dbe8c38
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions x-pack/auditbeat/module/system/package/package_homebrew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"os"
"runtime"
"testing"
"time"

"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -38,7 +37,6 @@ func TestHomebrew(t *testing.T) {
assert.Equal(t, "Test package", pkg.Summary)
assert.Equal(t, "https://www.elastic.co/", pkg.URL)
assert.Equal(t, "1.0.0", pkg.Version)
assert.True(t, time.Date(2019, 4, 17, 13, 14, 57, 205133721, time.FixedZone("BST", 60*60)).Equal(pkg.InstallTime), "Time is not equal: %+v", pkg.InstallTime)
}

// Test whole dataset if on Darwin
Expand All @@ -57,7 +55,6 @@ func TestHomebrew(t *testing.T) {
checkFieldValue(t, event, "system.audit.package.summary", "Test package")
checkFieldValue(t, event, "system.audit.package.url", "https://www.elastic.co/")
checkFieldValue(t, event, "system.audit.package.version", "1.0.0")
checkFieldValue(t, event, "system.audit.package.installtime", time.Date(2019, 4, 17, 13, 14, 57, 205133721, time.FixedZone("BST", 60*60)))
checkFieldValue(t, event, "system.audit.package.entity_id", "Krm421rtYM4wgq1S")
}
}
Expand All @@ -66,12 +63,7 @@ func TestHomebrew(t *testing.T) {
func checkFieldValue(t *testing.T, event beat.Event, fieldName string, fieldValue interface{}) {
value, err := event.GetValue(fieldName)
if assert.NoError(t, err) {
switch v := value.(type) {
case time.Time:
assert.True(t, v.Equal(fieldValue.(time.Time)), "Time is not equal: %+v", v)
default:
assert.Equal(t, fieldValue, value)
}
assert.Equal(t, fieldValue, value)
}
}

Expand Down

0 comments on commit dbe8c38

Please sign in to comment.