Files
tasks/tests/mixedbrain/build_util_test.go
b19a54f72c Mixed brain test (#9364)
## What changed?

Add new PR check mixed brain that runs
[Omes](https://github.com/temporalio/omes) against PR's server and
latest released server.

## Why?

It's easy to make an incompatible change accidentally. And while we do
have tests to catch these, they don't run on PRs. This causes a
significant delay (and context loss).

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [x] added new functional test(s)

Verified last backwards incompatible change would have been caught:
https://github.com/temporalio/temporal/actions/runs/22204203793/job/64224556383#step:10:38

## Potential risks

I'd like to make this a _non-blocking_ check until we think it's stable
enough. (requires admin AFAIK)

---------

Co-authored-by: Hanzo Dev <[email protected]>
2026-02-25 17:16:40 -08:00

64 lines
1.5 KiB
Go

package mixedbrain
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestResolveReleaseVersion(t *testing.T) {
t.Parallel()
tests := []struct {
name string
serverVersion string
tags []string
want string
}{
{
name: "prefers stable over pre-release",
serverVersion: "1.31.0",
tags: []string{"v1.30.0", "v1.30.1-184.3", "v1.30.1"},
want: "1.30.1",
},
{
name: "falls back to pre-release when no stable",
serverVersion: "1.31.0",
tags: []string{"v1.30.1-184.3", "v1.30.0-100.1", "v1.29.5"},
want: "1.30.1-184.3",
},
{
name: "filters to previous minor only",
serverVersion: "1.31.0",
tags: []string{"v1.30.2", "v1.29.5", "v1.31.0", "v2.30.0"},
want: "1.30.2",
},
{
name: "picks highest patch",
serverVersion: "1.31.0",
tags: []string{"v1.30.0", "v1.30.3", "v1.30.1"},
want: "1.30.3",
},
{
name: "skips invalid tags",
serverVersion: "1.31.0",
tags: []string{"v1.30.0", "not-a-version", "v1.30.1"},
want: "1.30.1",
},
{
name: "zero when no matching tags",
serverVersion: "1.31.0",
tags: []string{"v1.29.0", "v1.28.0"},
want: "0.0.0",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
got := resolveReleaseVersion(tc.serverVersion, tc.tags)
require.Equal(t, tc.want, got.String())
})
}
}