mirror of
https://github.com/hanzoai/team.git
synced 2026-09-30 01:57:35 +00:00
The server module named github.com/hanzoai/team/server/v8 — a path that resolves to the retired workspace's repository, not this one — while server/public still published github.com/mattermost/mattermost/server/public. Both are github.com/hanzoteam/server/... now, which is where this code actually lives. That second half is what made the binary unbootable. Upstream's public path stayed claimed by upstream, mattermost-plugin-ai imported it, and the build linked public/model twice; public/plugin's gob.Register then ran twice under one name and panicked at init, before main. Reverting the rename traded the brand for a working binary. Rebranding the plugin alongside it needs no such trade: the agents fork is github.com/hanzoteam/agents/v2 against our public module, so no module named mattermost/mattermost is in the graph at all. Measured: `go list -deps ./cmd/mattermost` names exactly one public/model, and it is ours.
88 lines
2.3 KiB
Go
88 lines
2.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/hanzoteam/server/server/public/model"
|
|
"github.com/hanzoteam/server/server/public/plugin"
|
|
)
|
|
|
|
func TestHealthCheckJob(t *testing.T) {
|
|
mainHelper.Parallel(t)
|
|
th := Setup(t)
|
|
|
|
tearDown, _, _ := SetAppEnvironmentWithPlugins(t, []string{
|
|
`
|
|
package main
|
|
|
|
import (
|
|
"github.com/hanzoteam/server/server/public/model"
|
|
"github.com/hanzoteam/server/server/public/plugin"
|
|
)
|
|
|
|
type MyPlugin struct {
|
|
plugin.MattermostPlugin
|
|
}
|
|
|
|
func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
|
|
panic("Uncaught error")
|
|
}
|
|
|
|
func main() {
|
|
plugin.ClientMain(&MyPlugin{})
|
|
}
|
|
`,
|
|
}, th.App, th.NewPluginAPI)
|
|
defer tearDown()
|
|
|
|
env := th.App.GetPluginsEnvironment()
|
|
job := env.GetPluginHealthCheckJob()
|
|
require.NotNil(t, job)
|
|
bundles := env.Active()
|
|
require.Equal(t, 1, len(bundles))
|
|
|
|
id := bundles[0].Manifest.Id
|
|
|
|
// First health check
|
|
hooks, err := env.HooksForPlugin(id)
|
|
require.NoError(t, err)
|
|
hooks.MessageWillBePosted(&plugin.Context{}, &model.Post{})
|
|
job.CheckPlugin(id)
|
|
bundles = env.Active()
|
|
require.Equal(t, 1, len(bundles))
|
|
require.Equal(t, id, bundles[0].Manifest.Id)
|
|
require.Equal(t, model.PluginStateRunning, env.GetPluginState(id))
|
|
|
|
// Second health check
|
|
hooks, err = env.HooksForPlugin(id)
|
|
require.NoError(t, err)
|
|
hooks.MessageWillBePosted(&plugin.Context{}, &model.Post{})
|
|
job.CheckPlugin(id)
|
|
bundles = env.Active()
|
|
require.Equal(t, 1, len(bundles))
|
|
require.Equal(t, id, bundles[0].Manifest.Id)
|
|
require.Equal(t, model.PluginStateRunning, env.GetPluginState(id))
|
|
|
|
// Third health check, plugin should be deactivated by the job
|
|
hooks, err = env.HooksForPlugin(id)
|
|
require.NoError(t, err)
|
|
hooks.MessageWillBePosted(&plugin.Context{}, &model.Post{})
|
|
job.CheckPlugin(id)
|
|
bundles = env.Active()
|
|
require.Equal(t, 0, len(bundles))
|
|
require.Equal(t, model.PluginStateFailedToStayRunning, env.GetPluginState(id))
|
|
|
|
// Activated manually, plugin should stay active
|
|
_, _, err = env.Activate(id)
|
|
require.NoError(t, err)
|
|
job.CheckPlugin(id)
|
|
bundles = env.Active()
|
|
require.Equal(t, 1, len(bundles))
|
|
require.Equal(t, model.PluginStateRunning, env.GetPluginState(id))
|
|
}
|