Files
seaweedfs/weed/admin/view/app/template_helpers_test.go
T
Chris LuandClaude Opus 5.5 69c2cff0d8 admin: show the configured S3 endpoint in the service account CLI example (#13395)
* admin: show the configured S3 endpoint in the service account CLI example

The credentials modal always printed AWS_ENDPOINT_URL=http://localhost:8333.
Use s3.public_endpoint from admin.toml (or weed mini's own S3 address) when
it is set, and keep localhost:8333 only as the fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: test the service account CLI example endpoint

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: shell-quote the S3 endpoint in the service account CLI example

A configured endpoint may contain characters such as ';' in its path, which
would split the copied export command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 11:24:34 -08:00

32 lines
911 B
Go

package app
import (
"testing"
"time"
)
func TestFormatLastHeartbeat(t *testing.T) {
if got := formatLastHeartbeat(time.Time{}); got != "unknown" {
t.Fatalf("zero time = %q, want unknown", got)
}
beat := time.Date(2026, 1, 2, 3, 4, 5, 0, time.Local)
if got := formatLastHeartbeat(beat); got != "2026-01-02 03:04:05" {
t.Fatalf("formatLastHeartbeat = %q", got)
}
}
func TestShellQuote(t *testing.T) {
tests := map[string]string{
"https://s3.example.com:8333/s3": "https://s3.example.com:8333/s3",
"https://proxy.example.com/s3;v1": "'https://proxy.example.com/s3;v1'",
"https://example.com/a b": "'https://example.com/a b'",
"https://example.com/it's": `'https://example.com/it'\''s'`,
"": "''",
}
for in, want := range tests {
if got := shellQuote(in); got != want {
t.Errorf("shellQuote(%q) = %q, want %q", in, got, want)
}
}
}