Skip to content

Commit 73d7126

Browse files
committed
testsuite: moved all generic subroutines into their own library
1 parent c6cfe21 commit 73d7126

File tree

11 files changed

+49
-304
lines changed

11 files changed

+49
-304
lines changed

arduino/discovery/discovery_client/go.sum

+5-4
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,17 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
292292
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
293293
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
294294
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
295+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
295296
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
296297
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
297298
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
298299
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
299300
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
300-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
301301
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
302+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
303+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
304+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
302305
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
303-
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
304-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
305-
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
306306
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
307307
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
308308
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -314,6 +314,7 @@ go.bug.st/downloader/v2 v2.1.1/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13R
314314
go.bug.st/relaxed-semver v0.9.0/go.mod h1:ug0/W/RPYUjliE70Ghxg77RDHmPxqpo7SHV16ijss7Q=
315315
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
316316
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
317+
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
317318
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
318319
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
319320
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=

client_example/go.sum

+4-3
Original file line numberDiff line numberDiff line change
@@ -275,16 +275,16 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
275275
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
276276
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
277277
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
278+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
278279
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
279280
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
280281
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
281282
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
282283
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
283284
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
285+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
286+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
284287
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
285-
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
286-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
287-
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
288288
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
289289
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
290290
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -296,6 +296,7 @@ go.bug.st/downloader/v2 v2.1.1/go.mod h1:VZW2V1iGKV8rJL2ZEGIDzzBeKowYv34AedJz13R
296296
go.bug.st/relaxed-semver v0.9.0/go.mod h1:ug0/W/RPYUjliE70Ghxg77RDHmPxqpo7SHV16ijss7Q=
297297
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
298298
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
299+
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
299300
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
300301
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
301302
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=

docsgen/go.sum

+5-4
Original file line numberDiff line numberDiff line change
@@ -343,18 +343,18 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
343343
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
344344
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
345345
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
346+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
346347
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
347348
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
348349
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
349350
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
350351
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
351-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
352352
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
353+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
354+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
355+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
353356
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
354357
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
355-
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
356-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
357-
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
358358
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
359359
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
360360
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -372,6 +372,7 @@ go.bug.st/serial v1.3.2 h1:6BFZZd/wngoL5PPYYTrFUounF54SIkykHpT98eq6zvk=
372372
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
373373
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45 h1:mACY1anK6HNCZtm/DK2Rf2ZPHggVqeB0+7rY9Gl6wyI=
374374
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
375+
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
375376
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
376377
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
377378
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=

go.mod

+3-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ require (
4040
github.com/spf13/cobra v1.2.1
4141
github.com/spf13/jwalterweatherman v1.1.0
4242
github.com/spf13/viper v1.8.1
43-
github.com/stretchr/testify v1.7.0
43+
github.com/stretchr/testify v1.8.0
4444
go.bug.st/cleanup v1.0.0
4545
go.bug.st/downloader/v2 v2.1.1
4646
go.bug.st/relaxed-semver v0.9.0
@@ -57,10 +57,7 @@ require (
5757
gopkg.in/yaml.v2 v2.4.0
5858
)
5959

60-
require (
61-
github.com/itchyny/gojq v0.12.8
62-
github.com/tidwall/gjson v1.14.1
63-
)
60+
require go.bug.st/testsuite v0.0.1
6461

6562
require (
6663
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
@@ -71,6 +68,7 @@ require (
7168
github.com/golang/protobuf v1.5.2 // indirect
7269
github.com/hashicorp/hcl v1.0.0 // indirect
7370
github.com/inconshreveable/mousetrap v1.0.0 // indirect
71+
github.com/itchyny/gojq v0.12.8 // indirect
7472
github.com/itchyny/timefmt-go v0.1.3 // indirect
7573
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
7674
github.com/josharian/intern v1.0.0 // indirect
@@ -90,8 +88,6 @@ require (
9088
github.com/spf13/pflag v1.0.5 // indirect
9189
github.com/src-d/gcfg v1.4.0 // indirect
9290
github.com/subosito/gotenv v1.2.0 // indirect
93-
github.com/tidwall/match v1.1.1 // indirect
94-
github.com/tidwall/pretty v1.2.0 // indirect
9591
github.com/xanzy/ssh-agent v0.2.1 // indirect
9692
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
9793
gopkg.in/ini.v1 v1.62.0 // indirect

go.sum

+6-7
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,18 @@ github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jW
345345
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
346346
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
347347
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
348+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
348349
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
349350
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
350351
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
351352
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
352353
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
353-
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
354354
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
355+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
356+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
357+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
355358
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
356359
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
357-
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
358-
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
359-
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
360-
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
361-
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
362-
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
363360
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
364361
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
365362
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -377,6 +374,8 @@ go.bug.st/serial v1.3.2 h1:6BFZZd/wngoL5PPYYTrFUounF54SIkykHpT98eq6zvk=
377374
go.bug.st/serial v1.3.2/go.mod h1:jDkjqASf/qSjmaOxHSHljwUQ6eHo/ZX/bxJLQqSlvZg=
378375
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45 h1:mACY1anK6HNCZtm/DK2Rf2ZPHggVqeB0+7rY9Gl6wyI=
379376
go.bug.st/serial.v1 v0.0.0-20180827123349-5f7892a7bb45/go.mod h1:dRSl/CVCTf56CkXgJMDOdSwNfo2g1orOGE/gBGdvjZw=
377+
go.bug.st/testsuite v0.0.1 h1:sdB+u46r+9ZVqROU1fl5utU773HktWDSc4hz6/jPK6A=
378+
go.bug.st/testsuite v0.0.1/go.mod h1:xCIDf97kf9USoz960Foy3CoquwhQmfuFRNh9git70as=
380379
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
381380
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
382381
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=

internal/integrationtest/arduino-cli.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/arduino/go-paths-helper"
3232
"github.com/fatih/color"
3333
"github.com/stretchr/testify/require"
34+
"go.bug.st/testsuite"
3435
"google.golang.org/grpc"
3536
)
3637

@@ -53,18 +54,19 @@ type ArduinoCLIConfig struct {
5354
}
5455

5556
// NewArduinoCliWithinEnvironment creates a new Arduino CLI client inside the given environment.
56-
func NewArduinoCliWithinEnvironment(t *testing.T, config *ArduinoCLIConfig, env *Environment) *ArduinoCLI {
57+
func NewArduinoCliWithinEnvironment(env *testsuite.Environment, config *ArduinoCLIConfig) *ArduinoCLI {
5758
color.NoColor = false
58-
cli := NewArduinoCli(t, config)
59-
staging := env.downloadsDir
59+
cli := NewArduinoCli(env.T(), config)
60+
staging := env.SharedDownloadsDir()
6061
if !config.UseSharedStagingFolder {
61-
staging = env.Root().Join("arduino15/staging")
62+
staging = env.RootDir().Join("arduino15/staging")
6263
}
6364
cli.cliEnvVars = []string{
64-
fmt.Sprintf("ARDUINO_DATA_DIR=%s", env.Root().Join("arduino15")),
65+
fmt.Sprintf("ARDUINO_DATA_DIR=%s", env.RootDir().Join("arduino15")),
6566
fmt.Sprintf("ARDUINO_DOWNLOADS_DIR=%s", staging),
66-
fmt.Sprintf("ARDUINO_SKETCHBOOK_DIR=%s", env.Root().Join("Arduino")),
67+
fmt.Sprintf("ARDUINO_SKETCHBOOK_DIR=%s", env.RootDir().Join("Arduino")),
6768
}
69+
env.RegisterCleanUpCallback(cli.CleanUp)
6870
return cli
6971
}
7072

internal/integrationtest/arduino-cli_daemon_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ import (
2525
"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
2626
"github.com/arduino/go-paths-helper"
2727
"github.com/stretchr/testify/require"
28+
"go.bug.st/testsuite"
2829
)
2930

3031
func TestArduinoCliDaemon(t *testing.T) {
3132
t.Skip("Deactivated for now")
3233
t.SkipNow()
3334

34-
env := NewEnvironment(t)
35+
env := testsuite.NewEnvironment(t)
3536
defer env.CleanUp()
3637

37-
cli := NewArduinoCliWithinEnvironment(t, &ArduinoCLIConfig{
38+
cli := NewArduinoCliWithinEnvironment(env, &ArduinoCLIConfig{
3839
ArduinoCLIPath: paths.New("..", "..", "arduino-cli"),
3940
UseSharedStagingFolder: true,
40-
}, env)
41-
defer cli.CleanUp()
41+
})
4242

4343
_, _, err := cli.Run("core", "update-index")
4444
require.NoError(t, err)

internal/integrationtest/core/core_test.go

+14-51
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,29 @@
1616
package core_test
1717

1818
import (
19-
"encoding/json"
2019
"fmt"
2120
"strings"
2221
"testing"
2322

2423
"github.com/arduino/arduino-cli/internal/integrationtest"
2524
"github.com/arduino/go-paths-helper"
2625
"github.com/stretchr/testify/require"
27-
"github.com/tidwall/gjson"
26+
"go.bug.st/testsuite"
27+
"go.bug.st/testsuite/requirejson"
2828
)
2929

3030
func TestCoreSearch(t *testing.T) {
31-
env := integrationtest.NewEnvironment(t)
31+
env := testsuite.NewEnvironment(t)
3232
defer env.CleanUp()
3333

34-
cli := integrationtest.NewArduinoCliWithinEnvironment(t, &integrationtest.ArduinoCLIConfig{
34+
cli := integrationtest.NewArduinoCliWithinEnvironment(env, &integrationtest.ArduinoCLIConfig{
3535
ArduinoCLIPath: paths.New("..", "..", "..", "arduino-cli"),
3636
UseSharedStagingFolder: true,
37-
}, env)
38-
defer cli.CleanUp()
37+
})
3938

4039
// Set up an http server to serve our custom index file
4140
test_index := paths.New("..", "testdata", "test_index.json")
42-
url, httpClose := integrationtest.HTTPServeFile(t, 8000, test_index)
43-
defer httpClose()
41+
url := env.HTTPServeFile(8000, test_index)
4442

4543
// Run update-index with our test index
4644
_, _, err := cli.Run("core", "update-index", "--additional-urls="+url.String())
@@ -53,47 +51,22 @@ func TestCoreSearch(t *testing.T) {
5351

5452
out, _, err = cli.Run("core", "search", "avr", "--format", "json")
5553
require.NoError(t, err)
56-
data := make([]interface{}, 0)
57-
require.NoError(t, json.Unmarshal(out, &data))
58-
require.NotEmpty(t, data)
59-
// same check using gjson lib
60-
require.NotEmpty(t, gjson.ParseBytes(out).Array())
54+
requirejson.NotEmpty(t, out)
6155

6256
// additional URL
6357
out, _, err = cli.Run("core", "search", "test_core", "--format", "json", "--additional-urls="+url.String())
6458
require.NoError(t, err)
65-
require.NoError(t, json.Unmarshal(out, &data))
66-
require.Len(t, data, 1)
59+
requirejson.Len(t, out, 1)
6760

6861
// show all versions
6962
out, _, err = cli.Run("core", "search", "test_core", "--all", "--format", "json", "--additional-urls="+url.String())
7063
require.NoError(t, err)
71-
require.NoError(t, json.Unmarshal(out, &data))
72-
require.Len(t, data, 2)
73-
// alternative check using gjson:
74-
require.Len(t, gjson.ParseBytes(out).Array(), 2)
75-
// alternative using gojq:
76-
integrationtest.JQQuery(t, out, "length", 2)
64+
requirejson.Len(t, out, 2)
65+
// requirejson.Len(t, out, 3) // Test failure
7766

7867
checkPlatformIsInJSONOutput := func(stdout []byte, id, version string) {
79-
// Alternative solution with gojq
80-
jqquery := fmt.Sprintf(`contains( [{id:"%s", latest:"%s"}] )`, id, version)
81-
integrationtest.JQQuery(t, out, jqquery, true, "platform %s@%s is missing from the output", id, version)
82-
83-
// Alternative solution with gjson
84-
// query := fmt.Sprintf("#(id=%s)#|#(latest=%s)", id, version)
85-
// if gjson.ParseBytes(out).Get(query).Exists() {
86-
// return
87-
// }
88-
// require.FailNowf(t, "Wrong output", "platform %s@%s is missing from the output", id, version)
89-
90-
// Alternative solution:
91-
// for _, platform := range gjson.ParseBytes(out).Array() {
92-
// if platform.Get("id").Str == id && platform.Get("latest").Str == version {
93-
// return
94-
// }
95-
// }
96-
// require.FailNowf(t, "Wrong output", "platform %s@%s is missing from the output", id, version)
68+
jqquery := fmt.Sprintf(`[{id:"%s", latest:"%s"}]`, id, version)
69+
requirejson.Contains(t, out, jqquery, "platform %s@%s is missing from the output", id, version)
9770
}
9871

9972
// Search all Retrokit platforms
@@ -127,20 +100,10 @@ func TestCoreSearch(t *testing.T) {
127100
out, _, err := cli.Run(args...)
128101
require.NoError(t, err)
129102

130-
// Alternative solution with gojq
131103
for _, id := range expectedIDs {
132-
jqquery := fmt.Sprintf(`contains( [{id:"%s"}] )`, id)
133-
integrationtest.JQQuery(t, out, jqquery, true, "platform %s is missing from the output", id)
104+
jqquery := fmt.Sprintf(`[{id:"%s"}]`, id)
105+
requirejson.Contains(t, out, jqquery, "platform %s is missing from the output", id)
134106
}
135-
136-
// Alternative solution with gjson
137-
// data := gjson.ParseBytes(out)
138-
// for _, expectedID := range expectedIDs {
139-
// query := fmt.Sprintf("#(id=%s)", expectedID)
140-
// if !data.Get(query).Exists() {
141-
// require.FailNowf(t, "Wrong output", "platform %s is missing from the output", expectedID)
142-
// }
143-
// }
144107
}
145108

146109
runSearch("mkr1000", "arduino:samd")

0 commit comments

Comments
 (0)