@@ -306,52 +306,66 @@ func TestAddDefaultMountOptions_ossfs2(t *testing.T) {
306306 tests := []struct {
307307 name string
308308 options []string
309- cfglevel string
309+ config * fpm. FuseContainerConfig
310310 defaultOpts string
311311 want []string
312312 }{
313313 {
314314 name : "empty option, empty config" ,
315315 options : []string {"others" },
316- want : []string {"others" , "log_level=info" , "log_dir=/dev/stdout" },
316+ want : []string {"others" , "log_level=info" , "log_dir=/dev/stdout" , "use_metrics=true" },
317317 },
318318 {
319319 name : "set option" ,
320- options : []string {"others" , "log_level=debug" , "log_dir=/tmp/ossfs2" , "others" , "use_metrics=true " },
321- want : []string {"others" , "log_level=debug" , "log_dir=/tmp/ossfs2" , "others" , "use_metrics=true " },
320+ options : []string {"others" , "log_level=debug" , "log_dir=/tmp/ossfs2" , "others" , "use_metrics=false " },
321+ want : []string {"others" , "log_level=debug" , "log_dir=/tmp/ossfs2" , "others" , "use_metrics=false " },
322322 },
323323 {
324- name : "set option, set config" ,
325- cfglevel : "info" ,
326- options : []string {"others" , "log_level=debug" , "others" },
327- want : []string {"others" , "log_level=debug" , "others" , "log_dir=/dev/stdout" },
324+ name : "set option, set config" ,
325+ config : & fpm.FuseContainerConfig {
326+ Dbglevel : fpm .DebugLevelInfo ,
327+ },
328+ options : []string {"others" , "log_level=debug" , "others" },
329+ want : []string {"others" , "log_level=debug" , "others" , "log_dir=/dev/stdout" , "use_metrics=true" },
328330 },
329331 {
330- name : "empty option, set config" ,
331- cfglevel : "debug" ,
332- options : []string {"others" },
333- want : []string {"others" , "log_level=debug" , "log_dir=/dev/stdout" },
332+ name : "empty option, set config" ,
333+ config : & fpm.FuseContainerConfig {
334+ Dbglevel : fpm .DebugLevelDebug ,
335+ },
336+ options : []string {"others" },
337+ want : []string {"others" , "log_level=debug" , "log_dir=/dev/stdout" , "use_metrics=true" },
334338 },
335339 {
336- name : "empty option, invalid config" ,
337- cfglevel : "invalid" ,
338- options : []string {"others" },
339- want : []string {"others" , "log_level=info" , "log_dir=/dev/stdout" },
340+ name : "empty option, invalid config" ,
341+ config : & fpm.FuseContainerConfig {
342+ Dbglevel : "invalid" ,
343+ },
344+ options : []string {"others" },
345+ want : []string {"others" , "log_level=info" , "log_dir=/dev/stdout" , "use_metrics=true" },
340346 },
341347 {
342348 name : "default options" ,
343- cfglevel : "" ,
344349 options : nil ,
345350 defaultOpts : "others,log_dir=/tmp/ossfs2" ,
346- want : []string {"others" , "log_dir=/tmp/ossfs2" , "log_level=info" },
351+ want : []string {"others" , "log_dir=/tmp/ossfs2" , "log_level=info" , "use_metrics=true" },
352+ },
353+ {
354+ name : "set metrics mode to disabled" ,
355+ config : & fpm.FuseContainerConfig {
356+ MetricsMode : fpm .MetricsModeDisabled ,
357+ },
358+ want : []string {"log_level=info" , "log_dir=/dev/stdout" },
347359 },
348360 }
349361 for _ , tt := range tests {
350362 t .Run (tt .name , func (t * testing.T ) {
351363 if tt .defaultOpts != "" {
352364 t .Setenv ("DEFAULT_OSSFS2_OPTIONS" , tt .defaultOpts )
353365 }
354- fakeOssfs .config .Dbglevel = tt .cfglevel
366+ if tt .config != nil {
367+ fakeOssfs .config = * tt .config
368+ }
355369 got := fakeOssfs .AddDefaultMountOptions (tt .options )
356370 assert .Equal (t , tt .want , got )
357371 })
0 commit comments