1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-06-23 00:07:52 +02:00
Files
opentelemetry-go/sdk/resource/process_test.go
renovate[bot] 05de07bcf5 chore(deps): update module github.com/antonboom/testifylint to v1.6.0 (#6440)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/Antonboom/testifylint](https://redirect.github.com/Antonboom/testifylint)
| `v1.5.2` -> `v1.6.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fAntonboom%2ftestifylint/v1.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fAntonboom%2ftestifylint/v1.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fAntonboom%2ftestifylint/v1.5.2/v1.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fAntonboom%2ftestifylint/v1.5.2/v1.6.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>Antonboom/testifylint
(github.com/Antonboom/testifylint)</summary>

###
[`v1.6.0`](https://redirect.github.com/Antonboom/testifylint/releases/tag/v1.6.0):
– new `equal-values` and `suite-method-signature`

[Compare
Source](https://redirect.github.com/Antonboom/testifylint/compare/v1.5.2...v1.6.0)

#### What's Changed

##### New checkers

- new checker `equal-values` by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/223](https://redirect.github.com/Antonboom/testifylint/pull/223)
- new checker `suite-method-signature` by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/228](https://redirect.github.com/Antonboom/testifylint/pull/228)

##### New features

- `len`: support len-len and value-len cases by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/204](https://redirect.github.com/Antonboom/testifylint/pull/204)
- `error-is-as`: support NotErrorAs by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/219](https://redirect.github.com/Antonboom/testifylint/pull/219)
- `useless-assert`: add NotElementsMatch and NotErrorAs by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/220](https://redirect.github.com/Antonboom/testifylint/pull/220)
- `formatter`: support non-string-message checks by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/221](https://redirect.github.com/Antonboom/testifylint/pull/221)
- `formatter`: warn on empty message by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/225](https://redirect.github.com/Antonboom/testifylint/pull/225)
- `empty`: support empty strings, Zero for strings and len + bubbled
useless-assert cases by
[@&#8203;ccoVeille](https://redirect.github.com/ccoVeille) in
[https://github.com/Antonboom/testifylint/pull/129](https://redirect.github.com/Antonboom/testifylint/pull/129)

##### New fixes

- `negative-positive`: remove untyping, ignore Negative for len
comparisons by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/226](https://redirect.github.com/Antonboom/testifylint/pull/226)
- fixes: support `assert.CollectT` by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/233](https://redirect.github.com/Antonboom/testifylint/pull/233)

##### Bump deps

- Upgrade testdata to v1.10.0 of testify by
[@&#8203;Antonboom](https://redirect.github.com/Antonboom) in
[https://github.com/Antonboom/testifylint/pull/218](https://redirect.github.com/Antonboom/testifylint/pull/218)
- Go 1.24 by [@&#8203;Antonboom](https://redirect.github.com/Antonboom)
in
[https://github.com/Antonboom/testifylint/pull/234](https://redirect.github.com/Antonboom/testifylint/pull/234)
- build(deps): bump golang.org/x/tools from 0.26.0 to 0.27.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/Antonboom/testifylint/pull/206](https://redirect.github.com/Antonboom/testifylint/pull/206)
- build(deps): bump rlespinasse/github-slug-action from 4.4.1 to 5.0.0
by [@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/Antonboom/testifylint/pull/207](https://redirect.github.com/Antonboom/testifylint/pull/207)
- build(deps): bump golang.org/x/tools from 0.27.0 to 0.29.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/Antonboom/testifylint/pull/214](https://redirect.github.com/Antonboom/testifylint/pull/214)

**Full Changelog**:
https://github.com/Antonboom/testifylint/compare/v1.5.2...v1.6.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDAuMiIsInVwZGF0ZWRJblZlciI6IjM5LjIwMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2025-03-13 14:31:12 -07:00

147 lines
3.5 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package resource_test
import (
"context"
"fmt"
"os"
"os/user"
"runtime"
"testing"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/otel/sdk/resource"
)
var (
fakePID = 123
fakeExecutablePath = "/fake/path/mock"
fakeCommandArgs = []string{"mock", "-t", "30"}
fakeOwner = "gopher"
fakeRuntimeName = "gcmock"
fakeRuntimeVersion = "go1.2.3"
fakeRuntimeOS = "linux"
fakeRuntimeArch = "amd64"
)
var (
fakeExecutableName = "mock"
fakeRuntimeDescription = "go version go1.2.3 linux/amd64"
)
var (
fakePidProvider = func() int { return fakePID }
fakeExecutablePathProvider = func() (string, error) { return fakeExecutablePath, nil }
fakeCommandArgsProvider = func() []string { return fakeCommandArgs }
fakeOwnerProvider = func() (*user.User, error) { return &user.User{Username: fakeOwner}, nil }
fakeRuntimeNameProvider = func() string { return fakeRuntimeName }
fakeRuntimeVersionProvider = func() string { return fakeRuntimeVersion }
fakeRuntimeOSProvider = func() string { return fakeRuntimeOS }
fakeRuntimeArchProvider = func() string { return fakeRuntimeArch }
)
var (
fakeExecutablePathProviderWithError = func() (string, error) {
return "", fmt.Errorf("unable to get process executable")
}
fakeOwnerProviderWithError = func() (*user.User, error) {
return nil, fmt.Errorf("unable to get process user")
}
)
func mockProcessAttributesProviders() {
resource.SetOSProviders(
fakePidProvider,
fakeExecutablePathProvider,
fakeCommandArgsProvider,
)
resource.SetRuntimeProviders(
fakeRuntimeNameProvider,
fakeRuntimeVersionProvider,
fakeRuntimeOSProvider,
fakeRuntimeArchProvider,
)
resource.SetUserProviders(
fakeOwnerProvider,
)
}
func mockProcessAttributesProvidersWithErrors() {
resource.SetOSProviders(
fakePidProvider,
fakeExecutablePathProviderWithError,
fakeCommandArgsProvider,
)
resource.SetRuntimeProviders(
fakeRuntimeNameProvider,
fakeRuntimeVersionProvider,
fakeRuntimeOSProvider,
fakeRuntimeArchProvider,
)
resource.SetUserProviders(
fakeOwnerProviderWithError,
)
}
func restoreAttributesProviders() {
resource.SetDefaultOSProviders()
resource.SetDefaultRuntimeProviders()
resource.SetDefaultUserProviders()
resource.SetDefaultOSDescriptionProvider()
resource.SetDefaultContainerProviders()
}
func TestWithProcessFuncsErrors(t *testing.T) {
mockProcessAttributesProvidersWithErrors()
t.Run("WithExecutablePath", testWithProcessExecutablePathError)
t.Run("WithOwner", testWithProcessOwnerError)
restoreAttributesProviders()
}
func TestCommandArgs(t *testing.T) {
require.Equal(t, os.Args, resource.CommandArgs())
}
func TestRuntimeName(t *testing.T) {
if runtime.Compiler == "gc" {
require.Equal(t, "go", resource.RuntimeName())
} else {
require.Equal(t, runtime.Compiler, resource.RuntimeName())
}
}
func TestRuntimeOS(t *testing.T) {
require.Equal(t, runtime.GOOS, resource.RuntimeOS())
}
func TestRuntimeArch(t *testing.T) {
require.Equal(t, runtime.GOARCH, resource.RuntimeArch())
}
func testWithProcessExecutablePathError(t *testing.T) {
ctx := context.Background()
res, err := resource.New(ctx,
resource.WithProcessExecutablePath(),
)
require.Error(t, err)
require.Equal(t, map[string]string{}, toMap(res))
}
func testWithProcessOwnerError(t *testing.T) {
ctx := context.Background()
res, err := resource.New(ctx,
resource.WithProcessOwner(),
)
require.Error(t, err)
require.Equal(t, map[string]string{}, toMap(res))
}