@@ -488,6 +488,380 @@ Describe "choco <_>" -ForEach $Command -Tag Chocolatey, SearchCommand, FindComma
488488 }
489489 }
490490
491+ Context " CCR Only Tests" - Tag CCR, CCROnly {
492+ Context " Searching of all package versions of Package13" {
493+ BeforeAll {
494+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions
495+ }
496+
497+ It " Exits with Success (0)" {
498+ $Output.ExitCode | Should - Be 0 - Because $Output.String
499+ }
500+
501+ It " Should contain packages and version with a space between them" {
502+ $Output.Lines | Should - Contain " Package13 11.11.11 Downloads cached for licensed users" - Because $Output.String
503+ }
504+
505+ It " Should contain a summary with 11 package versions" {
506+ $Output.Lines | Should - Contain " 11 packages found." - Because $Output.String
507+ }
508+ }
509+
510+ Context " Searching of all package versions of Package13 where packages have a download cache available" {
511+ BeforeAll {
512+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions -- download- cache
513+ }
514+
515+ It " Exits with Success (0)" {
516+ $Output.ExitCode | Should - Be 0 - Because $Output.String
517+ }
518+
519+ It " Should contain the following package versions" {
520+ $Output.Lines | Should - Contain " Package13 11.11.11 Downloads cached for licensed users" - Because $Output.String
521+ $Output.Lines | Should - Contain " Package13 9.9.9 Downloads cached for licensed users" - Because $Output.String
522+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
523+ $Output.Lines | Should - Contain " Package13 5.5.5 Downloads cached for licensed users" - Because $Output.String
524+ $Output.Lines | Should - Contain " Package13 3.3.3 Downloads cached for licensed users" - Because $Output.String
525+ $Output.Lines | Should - Contain " Package13 1.1.1 Downloads cached for licensed users" - Because $Output.String
526+ }
527+
528+ It " Should contain a summary with 6 package versions" {
529+ $Output.Lines | Should - Contain " 6 packages found." - Because $Output.String
530+ }
531+ }
532+
533+ Context " Searching of all package versions of Package13 where packages are not broken" {
534+ BeforeAll {
535+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions - -not - broken
536+ }
537+
538+ It " Exits with Success (0)" {
539+ $Output.ExitCode | Should - Be 0 - Because $Output.String
540+ }
541+
542+ It " Should contain the following package versions" {
543+ $Output.Lines | Should - Contain " Package13 11.11.11 Downloads cached for licensed users" - Because $Output.String
544+ $Output.Lines | Should - Contain " Package13 9.9.9 Downloads cached for licensed users" - Because $Output.String
545+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
546+ $Output.Lines | Should - Contain " Package13 5.5.5 Downloads cached for licensed users" - Because $Output.String
547+ $Output.Lines | Should - Contain " Package13 3.3.3 Downloads cached for licensed users" - Because $Output.String
548+ $Output.Lines | Should - Contain " Package13 1.1.1 Downloads cached for licensed users" - Because $Output.String
549+ }
550+
551+ It " Should contain a summary with 6 package versions" {
552+ $Output.Lines | Should - Contain " 6 packages found." - Because $Output.String
553+ }
554+ }
555+
556+ Context " Searching of all package versions of Package13 where packages are approved" {
557+ BeforeAll {
558+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions -- approved- only
559+ }
560+
561+ It " Exits with Success (0)" {
562+ $Output.ExitCode | Should - Be 0 - Because $Output.String
563+ }
564+
565+ It " Should contain the following package versions" {
566+ $Output.Lines | Should - Contain " Package13 10.10.10 [Approved] - Possibly Broken" - Because $Output.String
567+ $Output.Lines | Should - Contain " Package13 8.8.8 [Approved] - Possibly Broken" - Because $Output.String
568+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
569+ $Output.Lines | Should - Contain " Package13 6.6.6 [Approved] - Possibly Broken" - Because $Output.String
570+ $Output.Lines | Should - Contain " Package13 4.4.4 [Approved] - Possibly Broken" - Because $Output.String
571+ $Output.Lines | Should - Contain " Package13 2.2.2 [Approved] - Possibly Broken" - Because $Output.String
572+ }
573+
574+ It " Should contain a summary with 6 package versions" {
575+ $Output.Lines | Should - Contain " 6 packages found." - Because $Output.String
576+ }
577+ }
578+
579+ Context " Searching of all package versions of Package13 where packages are approved, have a download cache, and are not broken" {
580+ BeforeAll {
581+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions -- approved- only -- download- cache - -not - broken
582+ }
583+
584+ It " Exits with Success (0)" {
585+ $Output.ExitCode | Should - Be 0 - Because $Output.String
586+ }
587+
588+ It " Should contain the following package versions" {
589+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
590+ }
591+
592+ It " Should contain a summary with 1 package versions" {
593+ $Output.Lines | Should - Contain " 1 packages found." - Because $Output.String
594+ }
595+ }
596+
597+ Context " Searching of all package versions of Package13 where packages are approved, and are not broken" {
598+ BeforeAll {
599+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions -- approved- only - -not - broken
600+ }
601+
602+ It " Exits with Success (0)" {
603+ $Output.ExitCode | Should - Be 0 - Because $Output.String
604+ }
605+
606+ It " Should contain the following package versions" {
607+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
608+ }
609+
610+ It " Should contain a summary with 1 package versions" {
611+ $Output.Lines | Should - Contain " 1 packages found." - Because $Output.String
612+ }
613+ }
614+
615+ Context " Searching of all package versions of Package13 where packages are approved, have a download cache" {
616+ BeforeAll {
617+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions -- approved- only -- download- cache
618+ }
619+
620+ It " Exits with Success (0)" {
621+ $Output.ExitCode | Should - Be 0 - Because $Output.String
622+ }
623+
624+ It " Should contain the following package versions" {
625+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
626+ }
627+
628+ It " Should contain a summary with 1 package versions" {
629+ $Output.Lines | Should - Contain " 1 packages found." - Because $Output.String
630+ }
631+ }
632+
633+ Context " Searching of all package versions of Package13 where packages are not broken and have a download cache" {
634+ BeforeAll {
635+ $Output = Invoke-Choco $_ Package13 -- exact -- all- versions - -not - broken -- download- cache
636+ }
637+
638+ It " Exits with Success (0)" {
639+ $Output.ExitCode | Should - Be 0 - Because $Output.String
640+ }
641+
642+ It " Should contain the following package versions" {
643+ $Output.Lines | Should - Contain " Package13 11.11.11 Downloads cached for licensed users" - Because $Output.String
644+ $Output.Lines | Should - Contain " Package13 9.9.9 Downloads cached for licensed users" - Because $Output.String
645+ $Output.Lines | Should - Contain " Package13 7.7.7 [Approved] Downloads cached for licensed users" - Because $Output.String
646+ $Output.Lines | Should - Contain " Package13 5.5.5 Downloads cached for licensed users" - Because $Output.String
647+ $Output.Lines | Should - Contain " Package13 3.3.3 Downloads cached for licensed users" - Because $Output.String
648+ $Output.Lines | Should - Contain " Package13 1.1.1 Downloads cached for licensed users" - Because $Output.String
649+ }
650+
651+ It " Should contain a summary with 6 package versions" {
652+ $Output.Lines | Should - Contain " 6 packages found." - Because $Output.String
653+ }
654+ }
655+
656+ Context " Searching for the word 'test' should return lots of results" {
657+ BeforeAll {
658+ $Output = Invoke-Choco $_ test
659+ }
660+
661+ It " Exits with Success (0)" {
662+ $Output.ExitCode | Should - Be 0 - Because $Output.String
663+ }
664+
665+ # This is a reasonably fragile test, as
666+ # the number of packages may change over
667+ # time, but it is fine for now.
668+ It " Should contain a summary with 13 package versions" {
669+ $Output.Lines | Should - Contain " 44 packages found." - Because $Output.String
670+ }
671+ }
672+
673+ Context " Searching for the word 'test' with --id-starts-with" {
674+ BeforeAll {
675+ $Output = Invoke-Choco $_ test -- id- starts- with
676+ }
677+
678+ It " Exits with Success (0)" {
679+ $Output.ExitCode | Should - Be 0 - Because $Output.String
680+ }
681+
682+ It " Should contain the following packages" {
683+ $Output.Lines | Should - Contain " test-chocolateypath 0.1.0 [Approved]" - Because $Output.String
684+ }
685+
686+ It " Should contain a summary with 1 package versions" {
687+ $Output.Lines | Should - Contain " 1 packages found." - Because $Output.String
688+ }
689+ }
690+
691+ Context " Searching for the word 'test' with --by-id-only" {
692+ BeforeAll {
693+ $Output = Invoke-Choco $_ test -- by- id- only
694+ }
695+
696+ It " Exits with Success (0)" {
697+ $Output.ExitCode | Should - Be 0 - Because $Output.String
698+ }
699+
700+ It " Should contain the following packages" {
701+ $Output.Lines | Should - Contain " get-chocolateyunzip-test 0.0.2 [Approved]" - Because $Output.String
702+ $Output.Lines | Should - Contain " install-chocolateyinstallpackage-tests 1.0.0 [Approved]" - Because $Output.String
703+ $Output.Lines | Should - Contain " test-chocolateypath 0.1.0 [Approved]" - Because $Output.String
704+ }
705+
706+ It " Should contain a summary with 3 package versions" {
707+ $Output.Lines | Should - Contain " 3 packages found." - Because $Output.String
708+ }
709+ }
710+
711+ Context " Searching for the word 'package' with --by-tags-only" {
712+ BeforeAll {
713+ $Output = Invoke-Choco $_ Package -- by- tags- only
714+ }
715+
716+ It " Exits with Success (0)" {
717+ $Output.ExitCode | Should - Be 0 - Because $Output.String
718+ }
719+
720+ It " Should contain the following packages" {
721+ $Output.Lines | Should - Contain " msi.template 1.0.2 [Approved]" - Because $Output.String
722+ $Output.Lines | Should - Contain " zip.template 1.0.0 [Approved]" - Because $Output.String
723+ }
724+
725+ It " Should contain a summary with 2 package versions" {
726+ $Output.Lines | Should - Contain " 2 packages found." - Because $Output.String
727+ }
728+ }
729+
730+ Context " Doing an open-ended search with no ordering but limit-output" {
731+ BeforeAll {
732+ $Output = Invoke-Choco $_ -- limit-output
733+ }
734+
735+ It " Exits with Success (0)" {
736+ $Output.ExitCode | Should - Be 0 - Because $Output.String
737+ }
738+
739+ It " Should have add-path as first package" {
740+ $Output.Lines [0 ] | Should - Contain " add-path|1.0.0" - Because $Output.String
741+ }
742+
743+ It " Should contain 71 package versions" {
744+ $Output.Lines | Should - HaveCount 71 - Because $Output.String
745+ }
746+ }
747+
748+ Context " Doing an open-ended search with --order-by-popularity and limit-output" {
749+ BeforeAll {
750+ $Output = Invoke-Choco $_ -- limit-output -- order- by- popularity
751+ }
752+
753+ It " Exits with Success (0)" {
754+ $Output.ExitCode | Should - Be 0 - Because $Output.String
755+ }
756+
757+ It " Should have package13 as first package" {
758+ # There is some additional output
759+ # about the deprecation of
760+ # --order-by-popularity so we need to
761+ # actually grab the 3rd line
762+ $Output.Lines [0 ] | Should - Contain " '--order-by-popularity' is deprecated and will be removed in a future release." - Because $Output.String
763+ $Output.Lines [1 ] | Should - Contain " Use '--order-by='Popularity'' instead." - Because $Output.String
764+ $Output.Lines [2 ] | Should - Contain " package13|10.10.10" - Because $Output.String
765+ }
766+
767+ It " Should contain 71 package versions (73 lines)" {
768+ $Output.Lines | Should - HaveCount 73 - Because $Output.String
769+ }
770+ }
771+
772+ Context " Doing an open-ended search with --order-by='popularity' and limit-output" {
773+ BeforeAll {
774+ $Output = Invoke-Choco $_ -- limit-output -- order- by= ' popularity'
775+ }
776+
777+ It " Exits with Success (0)" {
778+ $Output.ExitCode | Should - Be 0 - Because $Output.String
779+ }
780+
781+ It " Should have package13 as first package" {
782+ $Output.Lines [0 ] | Should - Contain " package13|10.10.10" - Because $Output.String
783+ }
784+
785+ It " Should contain 71 package versions" {
786+ $Output.Lines | Should - HaveCount 71 - Because $Output.String
787+ }
788+ }
789+
790+ Context " Doing an open-ended search with --order-by='title' and limit-output" {
791+ BeforeAll {
792+ $Output = Invoke-Choco $_ -- limit-output -- order- by= ' title'
793+ }
794+
795+ It " Exits with Success (0)" {
796+ $Output.ExitCode | Should - Be 0 - Because $Output.String
797+ }
798+
799+ It " Should have business-only-license as first package" {
800+ $Output.Lines [0 ] | Should - Contain " business-only-license|19.0.0" - Because $Output.String
801+ }
802+
803+ It " Should contain 71 package versions" {
804+ $Output.Lines | Should - HaveCount 71 - Because $Output.String
805+ }
806+ }
807+
808+ Context " Doing an open-ended search with --order-by='id' and limit-output" {
809+ BeforeAll {
810+ $Output = Invoke-Choco $_ -- limit-output -- order- by= ' id'
811+ }
812+
813+ It " Exits with Success (0)" {
814+ $Output.ExitCode | Should - Be 0 - Because $Output.String
815+ }
816+
817+ It " Should have add-path as first package" {
818+ $Output.Lines [0 ] | Should - Contain " add-path|1.0.0" - Because $Output.String
819+ }
820+
821+ It " Should contain 71 package versions" {
822+ $Output.Lines | Should - HaveCount 71 - Because $Output.String
823+ }
824+ }
825+
826+ Context " Doing an open-ended search with --order-by='lastpublished' and limit-output" {
827+ BeforeAll {
828+ $Output = Invoke-Choco $_ -- limit-output -- order- by= ' lastpublished'
829+ }
830+
831+ It " Exits with Success (0)" {
832+ $Output.ExitCode | Should - Be 0 - Because $Output.String
833+ }
834+
835+ It " Should have package12 as first package" {
836+ $Output.Lines [0 ] | Should - Contain " package12|10.10.10" - Because $Output.String
837+ }
838+
839+ It " Should contain 71 package versions" {
840+ $Output.Lines | Should - HaveCount 71 - Because $Output.String
841+ }
842+ }
843+
844+ Context " Doing an open-ended search with --order-by='unsorted' and limit-output" {
845+ BeforeAll {
846+ $Output = Invoke-Choco $_ -- limit-output -- order- by= ' unsorted'
847+ }
848+
849+ It " Exits with Success (0)" {
850+ $Output.ExitCode | Should - Be 0 - Because $Output.String
851+ }
852+
853+ # Looks like CCR is defaulting to return
854+ # things based on popularity
855+ It " Should have package13 as first package" {
856+ $Output.Lines [0 ] | Should - Contain " package13|10.10.10" - Because $Output.String
857+ }
858+
859+ It " Should contain 71 package versions" {
860+ $Output.Lines | Should - HaveCount 71 - Because $Output.String
861+ }
862+ }
863+ }
864+
491865 # This needs to be the last test in this block, to ensure NuGet configurations aren't being created.
492866 Test-NuGetPaths
493867}
0 commit comments