MCPcopy
hub / github.com/ipfs/kubo / TestValidateImportConfig_UnixFSFileMaxLinks

Function TestValidateImportConfig_UnixFSFileMaxLinks

config/import_test.go:110–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestValidateImportConfig_UnixFSFileMaxLinks(t *testing.T) {
111 tests := []struct {
112 name string
113 maxLinks int64
114 wantErr bool
115 errMsg string
116 }{
117 {name: "valid 1", maxLinks: 1, wantErr: false},
118 {name: "valid 174", maxLinks: 174, wantErr: false},
119 {name: "valid 1000", maxLinks: 1000, wantErr: false},
120 {name: "invalid 0", maxLinks: 0, wantErr: true, errMsg: "must be positive"},
121 {name: "invalid -1", maxLinks: -1, wantErr: true, errMsg: "must be positive"},
122 }
123
124 for _, tt := range tests {
125 t.Run(tt.name, func(t *testing.T) {
126 cfg := &Import{
127 UnixFSFileMaxLinks: *NewOptionalInteger(tt.maxLinks),
128 }
129
130 err := ValidateImportConfig(cfg)
131
132 if tt.wantErr {
133 if err == nil {
134 t.Errorf("ValidateImportConfig() expected error for maxLinks=%d, got nil", tt.maxLinks)
135 } else if tt.errMsg != "" && !strings.Contains(err.Error(), tt.errMsg) {
136 t.Errorf("ValidateImportConfig() error = %v, want error containing %q", err, tt.errMsg)
137 }
138 } else {
139 if err != nil {
140 t.Errorf("ValidateImportConfig() unexpected error for maxLinks=%d: %v", tt.maxLinks, err)
141 }
142 }
143 })
144 }
145}
146
147func TestValidateImportConfig_UnixFSDirectoryMaxLinks(t *testing.T) {
148 tests := []struct {

Callers

nothing calls this directly

Calls 4

NewOptionalIntegerFunction · 0.85
ValidateImportConfigFunction · 0.85
RunMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected