-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ErikKalkoken/fix-issue-3
Fix issue 3
- Loading branch information
Showing
11 changed files
with
229 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package evenotification_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ErikKalkoken/evebuddy/internal/app" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/evenotification" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/eveuniverse" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/storage/testutil" | ||
"github.com/jarcoal/httpmock" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBilling(t *testing.T) { | ||
db, st, factory := testutil.New() | ||
defer db.Close() | ||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
eu := eveuniverse.New(st, nil) | ||
en := evenotification.New() | ||
en.EveUniverseService = eu | ||
ctx := context.Background() | ||
t.Run("CorpAllBillMsg full data", func(t *testing.T) { | ||
// given | ||
testutil.TruncateTables(db) | ||
httpmock.Reset() | ||
creditor := factory.CreateEveEntityCorporation(app.EveEntity{ID: 1000023}) | ||
debtor := factory.CreateEveEntityCorporation(app.EveEntity{ID: 98267621}) | ||
office := factory.CreateEveEntityInventoryType(app.EveEntity{ID: 27}) | ||
station := factory.CreateEveEntity(app.EveEntity{ID: 60003760, Category: app.EveEntityStation}) | ||
text := ` | ||
amount: 10000 | ||
billTypeID: 2 | ||
creditorID: 1000023 | ||
currentDate: 133678830021821155 | ||
debtorID: 98267621 | ||
dueDate: 133704743590000000 | ||
externalID: 27 | ||
externalID2: 60003760` | ||
title, body, err := en.RenderESI(ctx, "CorpAllBillMsg", text, time.Now()) | ||
if assert.NoError(t, err) { | ||
assert.Equal(t, "Bill issued for lease", title.ValueOrZero()) | ||
assert.Contains(t, body.ValueOrZero(), creditor.Name) | ||
assert.Contains(t, body.ValueOrZero(), debtor.Name) | ||
assert.Contains(t, body.ValueOrZero(), office.Name) | ||
assert.Contains(t, body.ValueOrZero(), station.Name) | ||
} | ||
}) | ||
t.Run("CorpAllBillMsg partial data", func(t *testing.T) { | ||
// given | ||
testutil.TruncateTables(db) | ||
httpmock.Reset() | ||
creditor := factory.CreateEveEntityCorporation(app.EveEntity{ID: 1000023}) | ||
debtor := factory.CreateEveEntityCorporation(app.EveEntity{ID: 98267621}) | ||
text := ` | ||
amount: 10000 | ||
billTypeID: 2 | ||
creditorID: 1000023 | ||
currentDate: 133678830021821155 | ||
debtorID: 98267621 | ||
dueDate: 133704743590000000 | ||
externalID: 0 | ||
externalID2: 0` | ||
title, body, err := en.RenderESI(ctx, "CorpAllBillMsg", text, time.Now()) | ||
if assert.NoError(t, err) { | ||
assert.Equal(t, "Bill issued for lease", title.ValueOrZero()) | ||
assert.Contains(t, body.ValueOrZero(), creditor.Name) | ||
assert.Contains(t, body.ValueOrZero(), debtor.Name) | ||
assert.Contains(t, body.ValueOrZero(), "?") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package evenotification_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/ErikKalkoken/evebuddy/internal/app" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/evenotification" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/eveuniverse" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/storage" | ||
"github.com/ErikKalkoken/evebuddy/internal/app/storage/testutil" | ||
"github.com/jarcoal/httpmock" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestTowerNotification(t *testing.T) { | ||
db, st, factory := testutil.New() | ||
defer db.Close() | ||
httpmock.Activate() | ||
defer httpmock.DeactivateAndReset() | ||
eu := eveuniverse.New(st, nil) | ||
en := evenotification.New() | ||
en.EveUniverseService = eu | ||
ctx := context.Background() | ||
t.Run("TowerAlertMsg full data", func(t *testing.T) { | ||
// given | ||
testutil.TruncateTables(db) | ||
httpmock.Reset() | ||
aggressorAlliance := factory.CreateEveEntityAlliance(app.EveEntity{ID: 3011}) | ||
factory.CreateEveEntityCorporation(app.EveEntity{ID: 2011}) | ||
factory.CreateEveEntityCharacter(app.EveEntity{ID: 1011}) | ||
type_ := factory.CreateEveType(storage.CreateEveTypeParams{ID: 16213}) | ||
moon := factory.CreateEveMoon(storage.CreateEveMoonParams{ID: 40161465}) | ||
text := ` | ||
aggressorAllianceID: 3011 | ||
aggressorCorpID: 2011 | ||
aggressorID: 1011 | ||
armorValue: 0.6950949076033535 | ||
hullValue: 1.0 | ||
moonID: 40161465 | ||
shieldValue: 0.3950949076033535 | ||
solarSystemID: 30002537 | ||
typeID: 16213` | ||
title, body, err := en.RenderESI(ctx, "TowerAlertMsg", text, time.Now()) | ||
if assert.NoError(t, err) { | ||
assert.Contains(t, title.ValueOrZero(), "is under attack") | ||
assert.Contains(t, body.ValueOrZero(), aggressorAlliance.Name) | ||
assert.Contains(t, body.ValueOrZero(), moon.Name) | ||
assert.Contains(t, body.ValueOrZero(), type_.Name) | ||
} | ||
}) | ||
t.Run("TowerAlertMsg partial data 1", func(t *testing.T) { | ||
// given | ||
testutil.TruncateTables(db) | ||
httpmock.Reset() | ||
aggressorAlliance := factory.CreateEveEntityAlliance(app.EveEntity{ID: 3011}) | ||
factory.CreateEveEntityCorporation(app.EveEntity{ID: 2011}) | ||
factory.CreateEveEntityCharacter(app.EveEntity{ID: 1011}) | ||
type_ := factory.CreateEveType(storage.CreateEveTypeParams{ID: 16213}) | ||
moon := factory.CreateEveMoon(storage.CreateEveMoonParams{ID: 40161465}) | ||
text := ` | ||
aggressorAllianceID: 3011 | ||
aggressorCorpID: 2011 | ||
aggressorID: 0 | ||
armorValue: 0.6950949076033535 | ||
hullValue: 1.0 | ||
moonID: 40161465 | ||
shieldValue: 0.3950949076033535 | ||
solarSystemID: 30002537 | ||
typeID: 16213` | ||
title, body, err := en.RenderESI(ctx, "TowerAlertMsg", text, time.Now()) | ||
if assert.NoError(t, err) { | ||
assert.Contains(t, title.ValueOrZero(), "is under attack") | ||
assert.Contains(t, body.ValueOrZero(), aggressorAlliance.Name) | ||
assert.Contains(t, body.ValueOrZero(), moon.Name) | ||
assert.Contains(t, body.ValueOrZero(), type_.Name) | ||
} | ||
}) | ||
t.Run("TowerAlertMsg partial data 1", func(t *testing.T) { | ||
// given | ||
testutil.TruncateTables(db) | ||
httpmock.Reset() | ||
aggressorAlliance := factory.CreateEveEntityAlliance(app.EveEntity{ID: 3011}) | ||
factory.CreateEveEntityCorporation(app.EveEntity{ID: 2011}) | ||
factory.CreateEveEntityCharacter(app.EveEntity{ID: 1011}) | ||
type_ := factory.CreateEveType(storage.CreateEveTypeParams{ID: 16213}) | ||
moon := factory.CreateEveMoon(storage.CreateEveMoonParams{ID: 40161465}) | ||
text := ` | ||
aggressorAllianceID: 3011 | ||
aggressorCorpID: 2011 | ||
aggressorID: 0 | ||
armorValue: 0.6950949076033535 | ||
hullValue: 1.0 | ||
moonID: 40161465 | ||
shieldValue: 0.3950949076033535 | ||
solarSystemID: 30002537 | ||
typeID: 16213` | ||
title, body, err := en.RenderESI(ctx, "TowerAlertMsg", text, time.Now()) | ||
if assert.NoError(t, err) { | ||
assert.Contains(t, title.ValueOrZero(), "is under attack") | ||
assert.Contains(t, body.ValueOrZero(), aggressorAlliance.Name) | ||
assert.Contains(t, body.ValueOrZero(), moon.Name) | ||
assert.Contains(t, body.ValueOrZero(), type_.Name) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Evebuddy is a companion app for Eve Online players. | ||
package main | ||
|
||
import ( | ||
|