mirror of
https://github.com/status-im/status-go.git
synced 2026-08-31 00:51:12 +00:00
Part of the Go project layout migration, item 27. Pure move plus import-path rewrite across 502 files. No API or behaviour change. `internal/` keeps the messaging application logic unimportable from outside the module, which is what the issue asks for -- status-go is consumed through the C-bindings in mobile/, not as a Go library. Things that had to follow the move, beyond the Go imports: - tools/generate-handlers/template.txt. messenger_handlers.go is generated, and the template hard-codes the imports it emits, so the generated file kept importing protocol/common and failed typecheck. - .gitignore. The ignore rule for that generated file was pinned to the old path; without moving it, a 1486-line generated file starts being tracked. - Makefile: the logosstorage and torrent test targets (both the archive packages and ./protocol itself), the archive README, migration-protocol. - scripts/run_unit_tests.sh, which names the protocol package explicitly to shard its tests. - scripts/cleanup_generated_files.sh and .golangci.yml. scripts/migration_check.sh also needed a fix that is not specific to this move: it validated every file the branch touched under a migration dir against the timestamp naming rule, and a directory rename makes every migration in it look newly added. It now excludes renames, so moving a migration is not mistaken for adding one. refs #7067
120 lines
2.4 KiB
Go
120 lines
2.4 KiB
Go
package requests
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestInitializeApplication_Validate(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
app InitializeApplication
|
|
wantErr bool
|
|
errType error
|
|
}{
|
|
{
|
|
name: "Valid with minimum required fields",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Missing DataDir",
|
|
app: InitializeApplication{},
|
|
wantErr: true,
|
|
errType: ErrInitializeApplicationInvalidDataDir,
|
|
},
|
|
{
|
|
name: "Invalid LogLevel",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "INVALID",
|
|
},
|
|
wantErr: true,
|
|
},
|
|
{
|
|
name: "Valid LogLevel - ERROR",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "ERROR",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Valid LogLevel - WARN",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "WARN",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Valid LogLevel - INFO",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "INFO",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Valid LogLevel - DEBUG",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "DEBUG",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Valid LogLevel - TRACE",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "TRACE",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "All valid log levels",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
LogLevel: "ERROR",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
{
|
|
name: "Full configuration with valid values",
|
|
app: InitializeApplication{
|
|
DataDir: "/valid/path",
|
|
MediaServerEnableTLS: ptr(true),
|
|
SentryDSN: "sentry-dsn",
|
|
LogDir: "/logs/path",
|
|
LogEnabled: true,
|
|
LogLevel: "INFO",
|
|
APILoggingEnabled: true,
|
|
MetricsEnabled: true,
|
|
MetricsAddress: "localhost:8545",
|
|
},
|
|
wantErr: false,
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
err := tt.app.Validate()
|
|
|
|
if (err != nil) != tt.wantErr {
|
|
t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr)
|
|
return
|
|
}
|
|
|
|
if tt.errType != nil && err != tt.errType {
|
|
t.Errorf("Validate() error type = %v, want %v", err, tt.errType)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// ptr returns a pointer to v.
|
|
func ptr[T any](v T) *T {
|
|
return &v
|
|
}
|