Exemplo n.º 1
0
        public async Task SearchReturnsOk()
        {
            await _app.AddPackageAsync(_packageStream);

            using var response = await _client.GetAsync("v3/search");

            var content = await response.Content.ReadAsStreamAsync();

            var json = content.ToPrettifiedJson();

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
            Assert.Equal(@"{
  ""@context"": {
    ""@vocab"": ""http://schema.nuget.org/schema#"",
    ""@base"": ""http://localhost/v3/registration""
  },
  ""totalHits"": 1,
  ""data"": [
    {
      ""id"": ""TestData"",
      ""version"": ""1.2.3"",
      ""description"": ""Test description"",
      ""authors"": [
        ""Test author""
      ],
      ""iconUrl"": """",
      ""licenseUrl"": """",
      ""projectUrl"": """",
      ""registration"": ""http://localhost/v3/registration/testdata/index.json"",
      ""summary"": """",
      ""tags"": [],
      ""title"": """",
      ""totalDownloads"": 0,
      ""versions"": [
        {
          ""@id"": ""http://localhost/v3/registration/testdata/1.2.3.json"",
          ""version"": ""1.2.3"",
          ""downloads"": 0
        }
      ]
    }
  ]
}", json);
        }
Exemplo n.º 2
0
        public async Task SearchReturnsResults()
        {
            await _app.AddPackageAsync(_packageStream);

            var resource = await _repository.GetResourceAsync <PackageSearchResource>();

            var searchFilter = new SearchFilter(includePrerelease: true);

            var results = await resource.SearchAsync(
                "",
                searchFilter,
                skip : 0,
                take : 20,
                _logger,
                _cancellationToken);

            var result = Assert.Single(results);

            Assert.Equal("TestData", result.Identity.Id);
            Assert.Equal("1.2.3", result.Identity.Version.ToNormalizedString());
            Assert.Equal("Test description", result.Description);
            Assert.Equal("Test author", result.Authors);
            Assert.Equal(0, result.DownloadCount);

            var versions = await result.GetVersionsAsync();

            var version = Assert.Single(versions);

            Assert.Equal("1.2.3", version.Version.ToNormalizedString());
            Assert.Equal(0, version.DownloadCount);
        }
Exemplo n.º 3
0
        public async Task SearchReturnsResults()
        {
            await _app.AddPackageAsync(_packageStream);

            var results = await _client.SearchAsync();

            var result  = Assert.Single(results);
            var author  = Assert.Single(result.Authors);
            var version = Assert.Single(result.Versions);

            Assert.Equal("TestData", result.PackageId);
            Assert.Equal("1.2.3", result.Version);
            Assert.Equal("Test description", result.Description);
            Assert.Equal("Test author", author);
            Assert.Equal(0, result.TotalDownloads);

            Assert.Equal("1.2.3", version.Version);
            Assert.Equal(0, version.Downloads);
        }
Exemplo n.º 4
0
        public async Task SearchExcludesUpstream()
        {
            await _upstream.AddPackageAsync(_packageStream);

            using var downstreamResponse = await _downstreamClient.GetAsync("v3/search");

            var downstreamContent = await downstreamResponse.Content.ReadAsStreamAsync();

            var downstreamJson = downstreamContent.ToPrettifiedJson();

            // The downstream package source should not have the package.
            Assert.Equal(HttpStatusCode.OK, downstreamResponse.StatusCode);
            Assert.Equal(@"{
  ""@context"": {
    ""@vocab"": ""http://schema.nuget.org/schema#"",
    ""@base"": ""http://localhost/v3/registration""
  },
  ""totalHits"": 0,
  ""data"": []
}", downstreamJson);
        }