@@ -73,18 +73,18 @@ func Test_newNodeLogQuery(t *testing.T) {
7373		want     * nodeLogQuery 
7474		wantErr  bool 
7575	}{
76- 		{name : "empty" , query : url.Values {}, want : nil },
77- 		{query : url.Values {"unknown" : []string {"true" }}, want : nil },
76+ 		{name : "empty" , query : url.Values {}, want : & nodeLogQuery {} },
77+ 		{query : url.Values {"unknown" : []string {"true" }}, want : & nodeLogQuery {} },
7878
79- 		{query : url.Values {"sinceTime" : []string {"" }}, want : nil },
79+ 		{query : url.Values {"sinceTime" : []string {"" }}, want : & nodeLogQuery {} },
8080		{query : url.Values {"sinceTime" : []string {"2019-12-04 02:00:00" }}, wantErr : true },
8181		{query : url.Values {"sinceTime" : []string {"2019-12-04 02:00:00.000" }}, wantErr : true },
8282		{query : url.Values {"sinceTime" : []string {"2019-12-04 02" }}, wantErr : true },
8383		{query : url.Values {"sinceTime" : []string {"2019-12-04 02:00" }}, wantErr : true },
8484		{query : url.Values {"sinceTime" : []string {validTimeValue }},
8585			want : & nodeLogQuery {options : options {SinceTime : & validT }}},
8686
87- 		{query : url.Values {"untilTime" : []string {"" }}, want : nil },
87+ 		{query : url.Values {"untilTime" : []string {"" }}, want : & nodeLogQuery {} },
8888		{query : url.Values {"untilTime" : []string {"2019-12-04 02:00:00" }}, wantErr : true },
8989		{query : url.Values {"untilTime" : []string {"2019-12-04 02:00:00.000" }}, wantErr : true },
9090		{query : url.Values {"untilTime" : []string {"2019-12-04 02" }}, wantErr : true },
@@ -98,7 +98,7 @@ func Test_newNodeLogQuery(t *testing.T) {
9898
9999		{query : url.Values {"pattern" : []string {"foo" }}, want : & nodeLogQuery {options : options {Pattern : "foo" }}},
100100
101- 		{query : url.Values {"boot" : []string {"" }}, want : nil },
101+ 		{query : url.Values {"boot" : []string {"" }}, want : & nodeLogQuery {} },
102102		{query : url.Values {"boot" : []string {"0" }}, want : & nodeLogQuery {options : options {Boot : intPtr (0 )}}},
103103		{query : url.Values {"boot" : []string {"-23" }}, want : & nodeLogQuery {options : options {Boot : intPtr (- 23 )}}},
104104		{query : url.Values {"boot" : []string {"foo" }}, wantErr : true },
@@ -111,6 +111,11 @@ func Test_newNodeLogQuery(t *testing.T) {
111111		{query : url.Values {"query" : []string {"foo" , "/bar" }}, want : & nodeLogQuery {Services : []string {"foo" },
112112			Files : []string {"/bar" }}},
113113		{query : url.Values {"query" : []string {"/foo" , `\bar` }}, want : & nodeLogQuery {Files : []string {"/foo" , `\bar` }}},
114+ 		{query : url.Values {"unit" : []string {"" }}, wantErr : true },
115+ 		{query : url.Values {"unit" : []string {"   " , "    " }}, wantErr : true },
116+ 		{query : url.Values {"unit" : []string {"foo" }}, want : & nodeLogQuery {Services : []string {"foo" }}},
117+ 		{query : url.Values {"unit" : []string {"foo" , "bar" }}, want : & nodeLogQuery {Services : []string {"foo" , "bar" }}},
118+ 		{query : url.Values {"unit" : []string {"foo" , "/bar" }}, want : & nodeLogQuery {Services : []string {"foo" , "/bar" }}},
114119	}
115120	for  _ , tt  :=  range  tests  {
116121		t .Run (tt .query .Encode (), func (t  * testing.T ) {
@@ -165,10 +170,12 @@ func Test_nodeLogQuery_validate(t *testing.T) {
165170		pattern   =  "foo" 
166171		invalid   =  "foo\\ " 
167172	)
168- 	since , err  :=  time .Parse (time .RFC3339 , "2023-01-04T02:00:00Z" )
173+ 	sinceTime , err  :=  time .Parse (time .RFC3339 , "2023-01-04T02:00:00Z" )
169174	assert .NoError (t , err )
170- 	until , err  :=  time .Parse (time .RFC3339 , "2023-02-04T02:00:00Z" )
175+ 	untilTime , err  :=  time .Parse (time .RFC3339 , "2023-02-04T02:00:00Z" )
171176	assert .NoError (t , err )
177+ 	since  :=  "2019-12-04 02:00:00" 
178+ 	until  :=  "2019-12-04 03:00:00" 
172179
173180	tests  :=  []struct  {
174181		name      string 
@@ -177,23 +184,37 @@ func Test_nodeLogQuery_validate(t *testing.T) {
177184		options   options 
178185		wantErr   bool 
179186	}{
180- 		{name : "empty" ,  wantErr :  true },
181- 		{name : "empty with options" , options : options {SinceTime : & since },  wantErr :  true },
187+ 		{name : "empty" },
188+ 		{name : "empty with options" , options : options {SinceTime : & sinceTime } },
182189		{name : "one service" , Services : []string {service1 }},
183190		{name : "two services" , Services : []string {service1 , service2 }},
184191		{name : "one service one file" , Services : []string {service1 }, Files : []string {file1 }, wantErr : true },
185192		{name : "two files" , Files : []string {file1 , file2 }, wantErr : true },
186193		{name : "one file options" , Files : []string {file1 }, options : options {Pattern : pattern }, wantErr : true },
187194		{name : "invalid pattern" , Services : []string {service1 }, options : options {Pattern : invalid }, wantErr : true },
188- 		{name : "since" , Services : []string {service1 }, options : options {SinceTime : & since }},
189- 		{name : "until" , Services : []string {service1 }, options : options {UntilTime : & until }},
190- 		{name : "since until" , Services : []string {service1 }, options : options {SinceTime : & until , UntilTime : & since },
191- 			wantErr : true },
192- 		// boot is not supported on Windows. 
193- 		{name : "boot" , Services : []string {service1 }, options : options {Boot : intPtr (- 1 )}, wantErr : runtime .GOOS  ==  "windows" },
195+ 		{name : "sinceTime" , Services : []string {service1 }, options : options {SinceTime : & sinceTime }},
196+ 		{name : "untilTime" , Services : []string {service1 }, options : options {UntilTime : & untilTime }},
197+ 		{name : "sinceTime untilTime" , Services : []string {service1 }, options : options {SinceTime : & untilTime ,
198+ 			UntilTime : & sinceTime }, wantErr : true },
199+ 		{name : "boot" , Services : []string {service1 }, options : options {Boot : intPtr (- 1 )}},
194200		{name : "boot out of range" , Services : []string {service1 }, options : options {Boot : intPtr (1 )}, wantErr : true },
195201		{name : "tailLines" , Services : []string {service1 }, options : options {TailLines : intPtr (100 )}},
196202		{name : "tailLines out of range" , Services : []string {service1 }, options : options {TailLines : intPtr (100000 )}},
203+ 		{name : "since" , Services : []string {service1 }, options : options {ocAdm : ocAdm {Since : since }}},
204+ 		{name : "since RFC3339" , Services : []string {service1 }, options : options {ocAdm : ocAdm {Since : sinceTime .String ()}}, wantErr : true },
205+ 		{name : "until" , Services : []string {service1 }, options : options {ocAdm : ocAdm {Until : until }}},
206+ 		{name : "until RFC3339" , Services : []string {service1 }, options : options {ocAdm : ocAdm {Until : untilTime .String ()}}, wantErr : true },
207+ 		{name : "since sinceTime" , Services : []string {service1 }, options : options {SinceTime : & sinceTime ,
208+ 			ocAdm : ocAdm {Since : since }}, wantErr : true },
209+ 		{name : "until sinceTime" , Services : []string {service1 }, options : options {SinceTime : & sinceTime ,
210+ 			ocAdm : ocAdm {Until : until }}, wantErr : true },
211+ 		{name : "since untilTime" , Services : []string {service1 }, options : options {UntilTime : & untilTime ,
212+ 			ocAdm : ocAdm {Since : since }}, wantErr : true },
213+ 		{name : "until untilTime" , Services : []string {service1 }, options : options {UntilTime : & untilTime ,
214+ 			ocAdm : ocAdm {Until : until }}, wantErr : true },
215+ 		{name : "format" , Services : []string {service1 }, options : options {ocAdm : ocAdm {Format : "cat" }}},
216+ 		{name : "format invalid" , Services : []string {service1 }, options : options {ocAdm : ocAdm {Format : "foo" }},
217+ 			wantErr : true },
197218	}
198219	for  _ , tt  :=  range  tests  {
199220		t .Run (tt .name , func (t  * testing.T ) {
0 commit comments