mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
49 lines
959 B
Go
49 lines
959 B
Go
package command
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestMetaColorize(t *testing.T) {
|
|
var m *Meta
|
|
var args, args2 []string
|
|
|
|
// Test basic, color
|
|
m = new(Meta)
|
|
m.Color = true
|
|
args = []string{"foo", "bar"}
|
|
args2 = []string{"foo", "bar"}
|
|
args = m.process(args, false)
|
|
if !reflect.DeepEqual(args, args2) {
|
|
t.Fatalf("bad: %#v", args)
|
|
}
|
|
if m.Colorize().Disable {
|
|
t.Fatal("should not be disabled")
|
|
}
|
|
|
|
// Test basic, no change
|
|
m = new(Meta)
|
|
args = []string{"foo", "bar"}
|
|
args2 = []string{"foo", "bar"}
|
|
args = m.process(args, false)
|
|
if !reflect.DeepEqual(args, args2) {
|
|
t.Fatalf("bad: %#v", args)
|
|
}
|
|
if !m.Colorize().Disable {
|
|
t.Fatal("should be disabled")
|
|
}
|
|
|
|
// Test disable #1
|
|
m = new(Meta)
|
|
args = []string{"foo", "-no-color", "bar"}
|
|
args2 = []string{"foo", "bar"}
|
|
args = m.process(args, false)
|
|
if !reflect.DeepEqual(args, args2) {
|
|
t.Fatalf("bad: %#v", args)
|
|
}
|
|
if !m.Colorize().Disable {
|
|
t.Fatal("should be disabled")
|
|
}
|
|
}
|