(t *testing.T)
| 949 | } |
| 950 | |
| 951 | func TestUpdateSysCtls(t *testing.T) { |
| 952 | ctx := context.Background() |
| 953 | |
| 954 | tests := []struct { |
| 955 | name string |
| 956 | spec map[string]string |
| 957 | add []string |
| 958 | rm []string |
| 959 | expected map[string]string |
| 960 | }{ |
| 961 | { |
| 962 | name: "from scratch", |
| 963 | add: []string{"sysctl.zet=value-99", "sysctl.alpha=value-1"}, |
| 964 | expected: map[string]string{"sysctl.zet": "value-99", "sysctl.alpha": "value-1"}, |
| 965 | }, |
| 966 | { |
| 967 | name: "append new", |
| 968 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 969 | add: []string{"new.sysctl=newvalue"}, |
| 970 | expected: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2", "new.sysctl": "newvalue"}, |
| 971 | }, |
| 972 | { |
| 973 | name: "append duplicate is a no-op", |
| 974 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 975 | add: []string{"sysctl.one=value-1"}, |
| 976 | expected: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 977 | }, |
| 978 | { |
| 979 | name: "remove and append existing is a no-op", |
| 980 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 981 | add: []string{"sysctl.one=value-1"}, |
| 982 | rm: []string{"sysctl.one=value-1"}, |
| 983 | expected: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 984 | }, |
| 985 | { |
| 986 | name: "remove and append new should append", |
| 987 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 988 | add: []string{"new.sysctl=newvalue"}, |
| 989 | rm: []string{"new.sysctl=newvalue"}, |
| 990 | expected: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2", "new.sysctl": "newvalue"}, |
| 991 | }, |
| 992 | { |
| 993 | name: "update existing", |
| 994 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 995 | add: []string{"sysctl.one=newvalue"}, |
| 996 | expected: map[string]string{"sysctl.one": "newvalue", "sysctl.two": "value-2"}, |
| 997 | }, |
| 998 | { |
| 999 | name: "update existing twice", |
| 1000 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 1001 | add: []string{"sysctl.one=newvalue", "sysctl.one=evennewervalue"}, |
| 1002 | expected: map[string]string{"sysctl.one": "evennewervalue", "sysctl.two": "value-2"}, |
| 1003 | }, |
| 1004 | { |
| 1005 | name: "remove all", |
| 1006 | spec: map[string]string{"sysctl.one": "value-1", "sysctl.two": "value-2"}, |
| 1007 | rm: []string{"sysctl.one=value-1", "sysctl.two=value-2"}, |
| 1008 | expected: map[string]string{}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…