@@ -404,6 +404,106 @@ func TestAgent_ResourcesMonitoring(t *testing.T) {
404
404
}},
405
405
})
406
406
})
407
+
408
+ t .Run ("NonAbsPath" , func (t * testing.T ) {
409
+ resource .Test (t , resource.TestCase {
410
+ ProviderFactories : coderFactory (),
411
+ IsUnitTest : true ,
412
+ Steps : []resource.TestStep {{
413
+ Config : `
414
+ provider "coder" {
415
+ url = "https://example.com"
416
+ }
417
+ resource "coder_agent" "dev" {
418
+ os = "linux"
419
+ arch = "amd64"
420
+ resources_monitoring {
421
+ volume {
422
+ path = "tmp"
423
+ enabled = true
424
+ threshold = 80
425
+ }
426
+ }
427
+ }` ,
428
+ Check : nil ,
429
+ ExpectError : regexp .MustCompile (`volume path must be an absolute path` ),
430
+ }},
431
+ })
432
+ })
433
+
434
+ t .Run ("EmptyPath" , func (t * testing.T ) {
435
+ resource .Test (t , resource.TestCase {
436
+ ProviderFactories : coderFactory (),
437
+ IsUnitTest : true ,
438
+ Steps : []resource.TestStep {{
439
+ Config : `
440
+ provider "coder" {
441
+ url = "https://example.com"
442
+ }
443
+ resource "coder_agent" "dev" {
444
+ os = "linux"
445
+ arch = "amd64"
446
+ resources_monitoring {
447
+ volume {
448
+ path = ""
449
+ enabled = true
450
+ threshold = 80
451
+ }
452
+ }
453
+ }` ,
454
+ Check : nil ,
455
+ ExpectError : regexp .MustCompile (`volume path must not be empty` ),
456
+ }},
457
+ })
458
+ })
459
+
460
+ t .Run ("ThresholdMissing" , func (t * testing.T ) {
461
+ resource .Test (t , resource.TestCase {
462
+ ProviderFactories : coderFactory (),
463
+ IsUnitTest : true ,
464
+ Steps : []resource.TestStep {{
465
+ Config : `
466
+ provider "coder" {
467
+ url = "https://example.com"
468
+ }
469
+ resource "coder_agent" "dev" {
470
+ os = "linux"
471
+ arch = "amd64"
472
+ resources_monitoring {
473
+ volume {
474
+ path = "/volume1"
475
+ enabled = true
476
+ }
477
+ }
478
+ }` ,
479
+ Check : nil ,
480
+ ExpectError : regexp .MustCompile (`The argument "threshold" is required, but no definition was found.` ),
481
+ }},
482
+ })
483
+ })
484
+ t .Run ("EnabledMissing" , func (t * testing.T ) {
485
+ resource .Test (t , resource.TestCase {
486
+ ProviderFactories : coderFactory (),
487
+ IsUnitTest : true ,
488
+ Steps : []resource.TestStep {{
489
+ Config : `
490
+ provider "coder" {
491
+ url = "https://example.com"
492
+ }
493
+ resource "coder_agent" "dev" {
494
+ os = "linux"
495
+ arch = "amd64"
496
+ resources_monitoring {
497
+ memory {
498
+ threshold = 80
499
+ }
500
+ }
501
+ }` ,
502
+ Check : nil ,
503
+ ExpectError : regexp .MustCompile (`The argument "enabled" is required, but no definition was found.` ),
504
+ }},
505
+ })
506
+ })
407
507
}
408
508
409
509
func TestAgent_MetadataDuplicateKeys (t * testing.T ) {
0 commit comments