Skip to content

Commit

Permalink
Merge branch 'main' into noname
Browse files Browse the repository at this point in the history
  • Loading branch information
m5i-work authored Aug 4, 2022
2 parents 6317762 + fda65b9 commit 2d8be60
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions registry/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ import (
"testing"

"oras.land/oras-go/v2/registry"
. "oras.land/oras-go/v2/registry/internal/doc"
"oras.land/oras-go/v2/registry/remote"
)

var host string

const _ = ExampleUnplayable

func TestMain(m *testing.M) {
// Setup a local HTTPS registry
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down
26 changes: 26 additions & 0 deletions registry/internal/doc/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright The ORAS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package doc provides the constant can be used in example test files. Most of
// the example tests in this repo are fail to run on the GoDoc website because
// of the missing variables. In order to avoid confusing users, these tests
// should be unplayable on the GoDoc website, and this can be achieved by
// leveraging a dot import in the test files.
// Reference: https://pkg.go.dev/go/doc#Example
package doc

// ExampleUnplayable is used in examples test files in order to make example
// tests unplayable.
const ExampleUnplayable = true
2 changes: 2 additions & 0 deletions registry/remote/auth/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"
"testing"

. "oras.land/oras-go/v2/registry/internal/doc"
"oras.land/oras-go/v2/registry/remote/auth"
)

Expand All @@ -33,6 +34,7 @@ const (
password = "test_password"
accessToken = "test/access/token"
refreshToken = "test/refresh/token"
_ = ExampleUnplayable
)

var (
Expand Down
2 changes: 2 additions & 0 deletions registry/remote/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
artifactspec "github.com/oras-project/artifacts-spec/specs-go/v1"
"oras.land/oras-go/v2"
"oras.land/oras-go/v2/content"
. "oras.land/oras-go/v2/registry/internal/doc"
"oras.land/oras-go/v2/registry/remote"
)

Expand All @@ -45,6 +46,7 @@ const (
exampleUploadUUid = "0bc84d80-837c-41d9-824e-1907463c53b3"
ManifestDigest = "sha256:0b696106ecd0654e031f19e0a8cbd1aee4ad457d7c9cea881f07b12a930cd307"
ReferenceManifestDigest = "sha256:b2122d3fd728173dd6b68a0b73caa129302b78c78273ba43ead541a88169c855"
_ = ExampleUnplayable
)

var (
Expand Down

0 comments on commit 2d8be60

Please sign in to comment.