diff --git a/interactions/interactions.go b/interactions/interactions.go index f4b2ccc..0c43209 100644 --- a/interactions/interactions.go +++ b/interactions/interactions.go @@ -13,14 +13,14 @@ import ( type Interactions struct { PublicKey ed25519.PublicKey - Guilds discord.IGuildService + Guilds *discord.GuildService Router *InteractionRouter // if interactions are able to be used OK bool } -func NewInteractions(publicKey string, guildsService discord.IGuildService) *Interactions { +func NewInteractions(publicKey string, guildsService *discord.GuildService) *Interactions { return &Interactions{ PublicKey: ed25519.PublicKey(publicKey), Guilds: guildsService, diff --git a/interactions/interactions_test.go b/interactions/interactions_test.go index 1f94aa2..624eaf1 100644 --- a/interactions/interactions_test.go +++ b/interactions/interactions_test.go @@ -19,9 +19,9 @@ func TestNewInteractions(t *testing.T) { pub, _, _ := ed25519.GenerateKey(nil) key := hex.EncodeToString(pub) - gsm := &discord.GuildServiceMock{} + gs := &discord.GuildService{} - i := interactions.NewInteractions(key, gsm) + i := interactions.NewInteractions(key, gs) assert.True(t, i.OK, "interactions OK") assert.Equal(t, string(i.PublicKey), key, "public key accepted from args") } diff --git a/interactions/utils_test.go b/interactions/utils_test.go index 1d926e2..dbd8e32 100644 --- a/interactions/utils_test.go +++ b/interactions/utils_test.go @@ -16,13 +16,13 @@ import ( "github.com/stretchr/testify/assert" ) -func makeInteractions(t *testing.T) (*interactions.Interactions, *discord.GuildServiceMock, ed25519.PrivateKey) { +func makeInteractions(t *testing.T) (*interactions.Interactions, *discord.GuildService, ed25519.PrivateKey) { pub, priv, err := ed25519.GenerateKey(nil) if err != nil { t.Errorf("makeInteractions: failed to generate key: %v", err) } - gs := &discord.GuildServiceMock{} + gs := &discord.GuildService{} i := &interactions.Interactions{ PublicKey: pub, diff --git a/roleypoly/fiber.go b/roleypoly/fiber.go index 7617b48..2dd3f82 100644 --- a/roleypoly/fiber.go +++ b/roleypoly/fiber.go @@ -29,7 +29,7 @@ func CreateFiberApp() *fiber.App { return app } -func SetupControllers(app *fiber.App, dc discord.IDiscordClient, publicKey string) { +func SetupControllers(app *fiber.App, dc *discord.DiscordClient, publicKey string) { gs := discord.NewGuildService(dc) (&testing.TestingController{ diff --git a/testing/testing.go b/testing/testing.go index a2e48a1..607ce0e 100644 --- a/testing/testing.go +++ b/testing/testing.go @@ -16,6 +16,7 @@ type TestingController struct { func (t *TestingController) Routes(r fiber.Router) { r.Get("/picker/:version?", t.Picker) r.Get("/m/:server/:user", t.GetMember) + r.Get("/g/:server", t.GetGuild) } func (t *TestingController) Picker(c fiber.Ctx) error { @@ -39,5 +40,17 @@ func (t *TestingController) GetMember(c fiber.Ctx) error { types.NewAPIError(500, err.Error()).Send(c) } - return c.JSON(m) + return c.JSON(m.DiscordMember) +} + +func (t *TestingController) GetGuild(c fiber.Ctx) error { + serverID := c.Params("server") + + g, err := t.Guilds.GetGuild(serverID) + if err != nil { + log.Println("testing/get guild: ", err) + types.NewAPIError(500, err.Error()).Send(c) + } + + return c.JSON(g.DiscordGuild) }