feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
1 parent
aa6c3f50f4
commit
ceddfd3d6b
828 files changed
+122253
-13702
No files matched your search
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestErrorLogGroupProjection(t *testing.T) {
|
||||
for _, format := range []struct {
|
||||
name string
|
||||
fn func([]*Log)
|
||||
}{
|
||||
{"root", FormatRootLogs}, {"admin", FormatAdminLogs}, {"user", func(logs []*Log) { formatUserLogs(logs, 0) }},
|
||||
} {
|
||||
t.Run(format.name, func(t *testing.T) {
|
||||
metadata := `{"admin_info":{"request_policy":[{"channel_id":101,"group":"example-primary"},{"channel_id":102,"group":"example-preferred"}],"private":"secret"},"root_info":{"private":"secret"}}`
|
||||
logs := []*Log{
|
||||
{Type: LogTypeError, ChannelId: 102, Group: "default", Other: metadata},
|
||||
{Type: LogTypeError, ChannelId: 101, Group: "default", Other: metadata},
|
||||
{Type: LogTypeError, ChannelId: 0, Group: "default", Other: metadata},
|
||||
{Type: LogTypeConsume, ChannelId: 102, Group: "billed-group", Quota: 12345, Other: metadata},
|
||||
{Type: LogTypeError, ChannelId: 99, Group: "legacy", Other: metadata},
|
||||
{Type: LogTypeError, ChannelId: 102, Group: "legacy", Other: `invalid`},
|
||||
}
|
||||
format.fn(logs)
|
||||
for i, want := range []string{"example-preferred", "example-primary", "", "billed-group", "legacy", "legacy"} {
|
||||
require.Equal(t, want, logs[i].Group)
|
||||
}
|
||||
require.Equal(t, 12345, logs[3].Quota)
|
||||
if format.name == "user" {
|
||||
require.NotContains(t, logs[0].Other, "secret")
|
||||
require.NotContains(t, logs[0].Other, "request_policy")
|
||||
}
|
||||
format.fn(logs)
|
||||
require.Equal(t, "example-preferred", logs[0].Group)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user