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

chore(tests): fix tests by replacing obsolete entities and GUIDs #1091

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 22 additions & 8 deletions pkg/entities/entity_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ func TestIntegrationGetEntity(t *testing.T) {
t.Parallel()

// GUID of Dummy App
entityGUID := common.EntityGUID(testhelpers.IntegrationTestApplicationEntityGUID)
// entityGUID := common.EntityGUID(testhelpers.IntegrationTestApplicationEntityGUID)

// Temporarily using the GUID of a different app
entityGUID := common.EntityGUID("MzgwNjUyNnxBUE18QVBQTElDQVRJT058NTUzNDQ4MjAy")

pranav-new-relic marked this conversation as resolved.
Show resolved Hide resolved
client := newIntegrationTestClient(t)

result, err := client.GetEntity(entityGUID)
Expand All @@ -160,7 +164,8 @@ func TestIntegrationGetEntity(t *testing.T) {
assert.Equal(t, "APM", actual.Domain)
assert.Equal(t, EntityType("APM_APPLICATION_ENTITY"), actual.EntityType)
assert.Equal(t, entityGUID, actual.GUID)
assert.Equal(t, "Dummy App", actual.Name)
//assert.Equal(t, "Dummy App", actual.Name)
pranav-new-relic marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal(t, "Dummy App Pro Max", actual.Name)
assert.Equal(t, "https://one.newrelic.com/redirect/entity/"+string(entityGUID), actual.Permalink)
assert.Equal(t, true, actual.Reporting)
}
Expand All @@ -172,7 +177,10 @@ func TestIntegrationGetEntity_ApmEntity(t *testing.T) {
client := newIntegrationTestClient(t)

// GUID of Dummy App
result, err := client.GetEntity(testhelpers.IntegrationTestApplicationEntityGUID)
// result, err := client.GetEntity(testhelpers.IntegrationTestApplicationEntityGUID)

// Temporarily using the GUID of a different app
result, err := client.GetEntity("MzgwNjUyNnxBUE18QVBQTElDQVRJT058NTUzNDQ4MjAy")
pranav-new-relic marked this conversation as resolved.
Show resolved Hide resolved

if e, ok := err.(*http.GraphQLErrorResponse); ok {
if !e.IsDeprecated() {
Expand All @@ -191,9 +199,11 @@ func TestIntegrationGetEntity_ApmEntity(t *testing.T) {

// These are a bit fragile, if the above GUID ever changes...
// from ApmApplicationEntity / ApmApplicationEntityOutline
assert.Equal(t, 573482638, actual.ApplicationID)
// assert.Equal(t, 573482638, actual.ApplicationID)
assert.Equal(t, 553448202, actual.ApplicationID)
assert.Contains(t, acceptableAlertStatuses, actual.AlertSeverity)
assert.Equal(t, "nodejs", actual.Language)
// assert.Equal(t, "nodejs", actual.Language)
assert.Equal(t, "python", actual.Language)
assert.NotNil(t, actual.RunningAgentVersions)
assert.NotNil(t, actual.RunningAgentVersions.MinVersion)
assert.NotNil(t, actual.RunningAgentVersions.MaxVersion)
Expand Down Expand Up @@ -238,20 +248,24 @@ func TestIntegrationGetEntity_MobileEntity(t *testing.T) {

client := newIntegrationTestClient(t)

result, err := client.GetEntity("MzgwNjUyNnxNT0JJTEV8QVBQTElDQVRJT058NjAxMzc1OTAx")
result, err := client.GetEntity("MzgwNjUyNnxNT0JJTEV8QVBQTElDQVRJT058NjAxNDQ1MTYx")

if e, ok := err.(*http.GraphQLErrorResponse); ok {
if !e.IsDeprecated() {
require.NoError(t, e)
}
}
require.NotNil(t, (*result))

if *result == nil {
t.Skipf("Skipping this test as MobileApplicationEntities are fragile, need to be recreated")
}

require.NotNil(t, (*result))
actual := (*result).(*MobileApplicationEntity)

// These are a bit fragile, if the above GUID ever changes...
// from MobileApplicationEntity / MobileApplicationEntityOutline
assert.Equal(t, 601375901, actual.ApplicationID)
assert.Equal(t, 601445161, actual.ApplicationID)
pranav-new-relic marked this conversation as resolved.
Show resolved Hide resolved
assert.Equal(t, EntityAlertSeverityTypes.NOT_CONFIGURED, actual.AlertSeverity)
}

Expand Down
33 changes: 11 additions & 22 deletions pkg/entities/tags_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,7 @@ func TestIntegrationListTags(t *testing.T) {
require.Greater(t, len(actual), 0)
}

func TestIntegrationGetTagsForEntity(t *testing.T) {
t.Parallel()

var (
// GUID of Dummy App
testGUID = common.EntityGUID(testhelpers.IntegrationTestApplicationEntityGUID)
)

client := newIntegrationTestClient(t)

actual, err := client.GetTagsForEntity(testGUID)

require.NoError(t, err)
require.Greater(t, len(actual), 0)

actual, err = client.GetTagsForEntityMutable(testGUID)

require.NoError(t, err)
require.Greater(t, len(actual), 0)
}

func TestIntegrationTaggingAddTagsToEntity(t *testing.T) {
pranav-new-relic marked this conversation as resolved.
Show resolved Hide resolved
func TestIntegrationTaggingAddTagsToEntityAndGet(t *testing.T) {
t.Parallel()

var (
Expand All @@ -72,6 +51,16 @@ func TestIntegrationTaggingAddTagsToEntity(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, result)
require.Equal(t, 0, len(result.Errors))

actual, err := client.GetTagsForEntity(testGUID)

require.NoError(t, err)
require.Greater(t, len(actual), 0)

actual, err = client.GetTagsForEntityMutable(testGUID)

require.NoError(t, err)
require.Greater(t, len(actual), 0)
}

func TestIntegrationTaggingReplaceTagsOnEntity(t *testing.T) {
Expand Down
Loading