File: common_test.go

package info (click to toggle)
golang-github-azure-azure-sdk-for-go 68.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid
  • size: 556,256 kB
  • sloc: javascript: 196; sh: 96; makefile: 7
file content (47 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

package link_test

import (
	"context"
	"os"
	"testing"

	"github.com/Azure/azure-sdk-for-go/eng/tools/generator/cmd/issue/link"
	"github.com/Azure/azure-sdk-for-go/eng/tools/generator/cmd/issue/query"
)

func TestGetReadmeFromPath(t *testing.T) {
	token := os.Getenv("ACCESS_TOKEN")
	if len(token) == 0 {
		// skip this test when the token is not specified
		t.Skip()
	}
	ctx := context.Background()
	client := query.NewClientWithAccessToken(ctx, token)

	testdata := []struct {
		input    string
		expected link.Readme
	}{
		{
			input:    "specification/compute/resource-manager/Microsoft.Compute/stable/2020-12-01/compute.json",
			expected: "specification/compute/resource-manager/readme.md",
		},
		{
			input:    "specification/compute/resource-manager/Microsoft.Compute/stable/2020-12-01",
			expected: "specification/compute/resource-manager/readme.md",
		},
	}

	for _, c := range testdata {
		readme, err := link.GetReadmeFromPath(ctx, client, c.input)
		if err != nil {
			t.Fatalf("unexpected error: %+v", err)
		}
		if readme != c.expected {
			t.Fatalf("expected %s but got %s", c.expected, readme)
		}
	}
}