@@ -371,6 +371,164 @@ func TestNewGitPlugin(t *testing.T) {
371
371
},
372
372
expectedURL : "https://api.bitbucket.org/2.0/repositories/username/my-plugin/src/1234567/subdir" ,
373
373
},
374
+ {
375
+ name : "parse basic ssh plugin" ,
376
+ Include : []flake.Ref {
377
+ {
378
+ Type : "ssh" ,
379
+ Host : "localhost" ,
380
+ Owner : "username" ,
381
+ Repo : "my-plugin" ,
382
+ },
383
+ },
384
+
385
+ expected : gitPlugin {
386
+ ref : flake.Ref {
387
+ Type : "ssh" ,
388
+ Host : "localhost" ,
389
+ Owner : "username" ,
390
+ Repo : "my-plugin" ,
391
+ },
392
+ name : "username.my-plugin" ,
393
+ },
394
+ expectedURL : "git archive --format=tar.gz --remote=ssh://git@localhost/username/my-plugin main -o" ,
395
+ },
396
+ {
397
+ name : "parse ssh plugin with port" ,
398
+ Include : []flake.Ref {
399
+ {
400
+ Type : "ssh" ,
401
+ Host : "localhost" ,
402
+ Port : 9999 ,
403
+ Owner : "username" ,
404
+ Repo : "my-plugin" ,
405
+ },
406
+ },
407
+
408
+ expected : gitPlugin {
409
+ ref : flake.Ref {
410
+ Type : "ssh" ,
411
+ Host : "localhost" ,
412
+ Port : 9999 ,
413
+ Owner : "username" ,
414
+ Repo : "my-plugin" ,
415
+ },
416
+ name : "username.my-plugin" ,
417
+ },
418
+ expectedURL : "git archive --format=tar.gz --remote=ssh://git@localhost:9999/username/my-plugin main -o" ,
419
+ },
420
+ {
421
+ name : "parse ssh plugin with port and dir" ,
422
+ Include : []flake.Ref {
423
+ {
424
+ Type : "ssh" ,
425
+ Host : "localhost" ,
426
+ Port : 9999 ,
427
+ Owner : "username" ,
428
+ Repo : "my-plugin" ,
429
+ Dir : "subdir" ,
430
+ },
431
+ },
432
+
433
+ expected : gitPlugin {
434
+ ref : flake.Ref {
435
+ Type : "ssh" ,
436
+ Host : "localhost" ,
437
+ Port : 9999 ,
438
+ Owner : "username" ,
439
+ Repo : "my-plugin" ,
440
+ Dir : "subdir" ,
441
+ },
442
+ name : "username.my-plugin.subdir" ,
443
+ },
444
+ expectedURL : "git archive --format=tar.gz --remote=ssh://git@localhost:9999/username/my-plugin main subdir -o" ,
445
+ },
446
+ {
447
+ name : "parse ssh plugin with port, dir and rev" ,
448
+ Include : []flake.Ref {
449
+ {
450
+ Type : "ssh" ,
451
+ Host : "localhost" ,
452
+ Port : 9999 ,
453
+ Owner : "username" ,
454
+ Repo : "my-plugin" ,
455
+ Dir : "subdir" ,
456
+ Rev : "1234567" ,
457
+ },
458
+ },
459
+
460
+ expected : gitPlugin {
461
+ ref : flake.Ref {
462
+ Type : "ssh" ,
463
+ Host : "localhost" ,
464
+ Port : 9999 ,
465
+ Owner : "username" ,
466
+ Repo : "my-plugin" ,
467
+ Dir : "subdir" ,
468
+ Rev : "1234567" ,
469
+ },
470
+ name : "username.my-plugin.subdir" ,
471
+ },
472
+ expectedURL : "git archive --format=tar.gz --remote=ssh://git@localhost:9999/username/my-plugin 1234567 subdir -o" ,
473
+ },
474
+ {
475
+ name : "parse ssh plugin with port, dir and ref" ,
476
+ Include : []flake.Ref {
477
+ {
478
+ Type : "ssh" ,
479
+ Host : "localhost" ,
480
+ Port : 9999 ,
481
+ Owner : "username" ,
482
+ Repo : "my-plugin" ,
483
+ Dir : "subdir" ,
484
+ Ref : "some/branch" ,
485
+ },
486
+ },
487
+
488
+ expected : gitPlugin {
489
+ ref : flake.Ref {
490
+ Type : "ssh" ,
491
+ Host : "localhost" ,
492
+ Port : 9999 ,
493
+ Owner : "username" ,
494
+ Repo : "my-plugin" ,
495
+ Dir : "subdir" ,
496
+ Ref : "some/branch" ,
497
+ },
498
+ name : "username.my-plugin.subdir" ,
499
+ },
500
+ expectedURL : "git archive --format=tar.gz --remote=ssh://git@localhost:9999/username/my-plugin some/branch subdir -o" ,
501
+ },
502
+ {
503
+ name : "parse ssh plugin with port, dir, ref and ref" ,
504
+ Include : []flake.Ref {
505
+ {
506
+ Type : "ssh" ,
507
+ Host : "localhost" ,
508
+ Port : 9999 ,
509
+ Owner : "username" ,
510
+ Repo : "my-plugin" ,
511
+ Dir : "subdir" ,
512
+ Ref : "some/branch" ,
513
+ Rev : "1234567" ,
514
+ },
515
+ },
516
+
517
+ expected : gitPlugin {
518
+ ref : flake.Ref {
519
+ Type : "ssh" ,
520
+ Host : "localhost" ,
521
+ Port : 9999 ,
522
+ Owner : "username" ,
523
+ Repo : "my-plugin" ,
524
+ Dir : "subdir" ,
525
+ Ref : "some/branch" ,
526
+ Rev : "1234567" ,
527
+ },
528
+ name : "username.my-plugin.subdir" ,
529
+ },
530
+ expectedURL : "git archive --format=tar.gz --remote=ssh://git@localhost:9999/username/my-plugin 1234567 subdir -o" ,
531
+ },
374
532
}
375
533
376
534
for _ , testCase := range testCases {
0 commit comments