Skip to content

Commit

Permalink
Rewrite message hooks tests part2 (#658)
Browse files Browse the repository at this point in the history
* bump mattermost deps

* split out reaction.go

* split out message.go

* begin testing MessageHasBeenPosted

* Update server/permutation_test.go

Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>

* Update server/permutation_test.go

Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>

* go mod tidy

---------

Co-authored-by: Julien Tant <785518+JulienTant@users.noreply.github.com>
  • Loading branch information
lieut-data and JulienTant authored May 22, 2024
1 parent bccb4d3 commit 9846fb8
Show file tree
Hide file tree
Showing 12 changed files with 3,416 additions and 3,015 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ require (
github.com/hashicorp/go-plugin v1.6.0
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.9
github.com/mattermost/mattermost/server/public v0.0.18-0.20240404202637-65d589935ff9
github.com/mattermost/mattermost/server/v8 v8.0.0-20240404204026-0a3667bf58c5
github.com/mattermost/mattermost/server/public v0.1.3
github.com/mattermost/mattermost/server/v8 v8.0.0-20240520151130-4bdd8bb18e47
github.com/microsoft/kiota-abstractions-go v1.5.6
github.com/microsoft/kiota-http-go v1.3.1
github.com/microsoftgraph/msgraph-sdk-go v1.36.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ github.com/mattermost/ldap v0.0.0-20231116144001-0f480c025956 h1:Y1Tu/swM31pVwwb
github.com/mattermost/ldap v0.0.0-20231116144001-0f480c025956/go.mod h1:SRl30Lb7/QoYyohYeVBuqYvvmXSZJxZgiV3Zf6VbxjI=
github.com/mattermost/logr/v2 v2.0.21 h1:CMHsP+nrbRlEC4g7BwOk1GAnMtHkniFhlSQPXy52be4=
github.com/mattermost/logr/v2 v2.0.21/go.mod h1:kZkB/zqKL9e+RY5gB3vGpsyenC+TpuiOenjMkvJJbzc=
github.com/mattermost/mattermost/server/public v0.0.18-0.20240404202637-65d589935ff9 h1:4aARnThoH8ZaRpGTYwo90Z4tggN/4z8Co4q13qWw1hE=
github.com/mattermost/mattermost/server/public v0.0.18-0.20240404202637-65d589935ff9/go.mod h1:WeqCPudYLqk4HjjGvCMJwhtHMVvcNUTHIbrLmLjAD+4=
github.com/mattermost/mattermost/server/v8 v8.0.0-20240404204026-0a3667bf58c5 h1:8IBnGEFO7ERNE/n+28htdd5D1FEQGMZTroHSZUl/M2c=
github.com/mattermost/mattermost/server/v8 v8.0.0-20240404204026-0a3667bf58c5/go.mod h1:QGkZJfQJ+NVXTYisCmIyOL1F0GusghAPQEfx5taI0fI=
github.com/mattermost/mattermost/server/public v0.1.3 h1:A3hQ3rNCwHfKAVxe7Hk3Zd9p2pyUKRmxtRPnkWP5SFM=
github.com/mattermost/mattermost/server/public v0.1.3/go.mod h1:PDPb/iqzJJ5ZvK/m70oDF55AXN/cOvVFj96Yu4e6j+Q=
github.com/mattermost/mattermost/server/v8 v8.0.0-20240520151130-4bdd8bb18e47 h1:HAJ7UGlEltFZOjan7hOkX1I6q+73xel64ESSIlcCMDM=
github.com/mattermost/mattermost/server/v8 v8.0.0-20240520151130-4bdd8bb18e47/go.mod h1:qQjPPGKiugHw6Tunlmq3cVDkKFFbgtMxIvyNJoN+p3Y=
github.com/mattermost/morph v1.1.0 h1:Q9vrJbeM3s2jfweGheq12EFIzdNp9a/6IovcbvOQ6Cw=
github.com/mattermost/morph v1.1.0/go.mod h1:gD+EaqX2UMyyuzmF4PFh4r33XneQ8Nzi+0E8nXjMa3A=
github.com/mattermost/rsc v0.0.0-20160330161541-bbaefb05eaa0 h1:G9tL6JXRBMzjuD1kkBtcnd42kUiT6QDwxfFYu7adM6o=
Expand Down
2 changes: 1 addition & 1 deletion server/automute_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestUpdateAutomutingOnChannelCreated(t *testing.T) {
channel, err := th.p.API.GetGroupChannel([]string{connectedUserWithAutomute.Id, connectedUserWithoutAutomute.Id, teamsUser.Id})
require.Nil(t, err)

assertChannelNotAutomuted(t, th.p, channel.Id, connectedUserWithAutomute.Id)
assertChannelAutomuted(t, th.p, channel.Id, connectedUserWithAutomute.Id)
assertChannelNotAutomuted(t, th.p, channel.Id, connectedUserWithoutAutomute.Id)
assertChannelNotAutomuted(t, th.p, channel.Id, teamsUser.Id)
})
Expand Down
3 changes: 3 additions & 0 deletions server/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ func (th *testHelper) SetupRemoteUser(t *testing.T, team *model.Team) *model.Use
_, appErr = th.p.API.CreateTeamMember(team.Id, user.Id)
require.Nil(t, appErr)

err := th.p.store.SetUserInfo(user.Id, "t"+user.Id, nil)
require.NoError(t, err)

return user
}

Expand Down
20 changes: 1 addition & 19 deletions server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import (
"fmt"
"net"
"os"
"os/exec"
"path"
"strings"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -52,19 +50,6 @@ func (mt *mainT) FailNow() {
os.Exit(1)
}

// setupServerPath defines MM_SERVER_PATH correctly for server initialization. One day this won't
// be necessary at all.
func setupServerPath() error {
// Find the server to define MM_SERVER_PATH when running tests.
serverPath, err := exec.Command("go", "list", "-f", "'{{.Dir}}'", "-m", "github.com/mattermost/mattermost/server/v8").Output()
if err != nil {
return err
}
os.Setenv("MM_SERVER_PATH", strings.Trim(strings.TrimSpace(string(serverPath)), "'"))

return nil
}

// setupDatabase initializes a singleton Postgres testcontainer and mattermost_test database for
// use with tests.
func setupDatabase(mt *mainT) error {
Expand Down Expand Up @@ -210,10 +195,7 @@ var setupReattachEnvironmentOnce sync.Once
// *mainT to clean up once at termination.
func setupReattachEnvironment(mt *mainT) {
setupReattachEnvironmentOnce.Do(func() {
err := setupServerPath()
require.NoError(mt, err)

err = setupDatabase(mt)
err := setupDatabase(mt)
require.NoError(mt, err)

err = setupServer(mt)
Expand Down
Loading

0 comments on commit 9846fb8

Please sign in to comment.