Repository: open-telemetry/opentelemetry-go

Issue:
Remove `env.go` and `env_test.go` from `internal/internaltest`
This file contains unused types. It and its tests are not needed.

This is a [generated file](https://github.com/open-telemetry/opentelemetry-go/blob/ee442f9666634e4e0b2e392f6c3cd042faccbeea/internal/shared/README.md), so `internal/gen.go` will need to be updated.

Hints from issue comments:
@meyank-ssh: Hey! I've opened a PR to address this issue: https://github.com/open-telemetry/opentelemetry-go/pull/6556
Let me know if any changes are needed.@zenith12122: Hello is this still available. Can I work on this?@MrAlias: @zenith12122 this is not available. It has been assigned to @meyank-ssh. Please do take a look at our [other issues](https://github.com/open-telemetry/opentelemetry-go/issues) though. Thanks.

Solution patch:
diff --git a/internal/gen.go b/internal/gen.go
index 67a1b4e1d..aba2a841c 100644
--- a/internal/gen.go
+++ b/internal/gen.go
@@ -7,8 +7,6 @@ package internal // import "go.opentelemetry.io/otel/internal"
 //go:generate gotmpl --body=./shared/matchers/expecter.go.tmpl "--data={}" --out=matchers/expecter.go
 //go:generate gotmpl --body=./shared/matchers/temporal_matcher.go.tmpl "--data={}" --out=matchers/temporal_matcher.go
 
-//go:generate gotmpl --body=./shared/internaltest/env.go.tmpl "--data={}" --out=internaltest/env.go
-//go:generate gotmpl --body=./shared/internaltest/env_test.go.tmpl "--data={}" --out=internaltest/env_test.go
 //go:generate gotmpl --body=./shared/internaltest/errors.go.tmpl "--data={}" --out=internaltest/errors.go
 //go:generate gotmpl --body=./shared/internaltest/harness.go.tmpl "--data={\"matchersImportPath\": \"go.opentelemetry.io/otel/internal/matchers\"}" --out=internaltest/harness.go
 //go:generate gotmpl --body=./shared/internaltest/text_map_carrier.go.tmpl "--data={}" --out=internaltest/text_map_carrier.go



Test patch:
diff --git a/internal/internaltest/env.go b/internal/internaltest/env.go
deleted file mode 100644
index 58d415994..000000000
--- a/internal/internaltest/env.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// Code created by gotmpl. DO NOT MODIFY.
-// source: internal/shared/internaltest/env.go.tmpl
-
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-
-package internaltest // import "go.opentelemetry.io/otel/internal/internaltest"
-
-import (
-	"os"
-)
-
-type Env struct {
-	Name   string
-	Value  string
-	Exists bool
-}
-
-// EnvStore stores and recovers environment variables.
-type EnvStore interface {
-	// Records the environment variable into the store.
-	Record(key string)
-
-	// Restore recovers the environment variables in the store.
-	Restore() error
-}
-
-var _ EnvStore = (*envStore)(nil)
-
-type envStore struct {
-	store map[string]Env
-}
-
-func (s *envStore) add(env Env) {
-	s.store[env.Name] = env
-}
-
-func (s *envStore) Restore() error {
-	var err error
-	for _, v := range s.store {
-		if v.Exists {
-			err = os.Setenv(v.Name, v.Value)
-		} else {
-			err = os.Unsetenv(v.Name)
-		}
-		if err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-func (s *envStore) setEnv(key, value string) error {
-	s.Record(key)
-
-	err := os.Setenv(key, value)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
-func (s *envStore) Record(key string) {
-	originValue, exists := os.LookupEnv(key)
-	s.add(Env{
-		Name:   key,
-		Value:  originValue,
-		Exists: exists,
-	})
-}
-
-func NewEnvStore() EnvStore {
-	return newEnvStore()
-}
-
-func newEnvStore() *envStore {
-	return &envStore{store: make(map[string]Env)}
-}
-
-func SetEnvVariables(env map[string]string) (EnvStore, error) {
-	envStore := newEnvStore()
-
-	for k, v := range env {
-		err := envStore.setEnv(k, v)
-		if err != nil {
-			return nil, err
-		}
-	}
-	return envStore, nil
-}
diff --git a/internal/internaltest/env_test.go b/internal/internaltest/env_test.go
deleted file mode 100644
index 53a84e9eb..000000000
--- a/internal/internaltest/env_test.go
+++ /dev/null
@@ -1,226 +0,0 @@
-// Code created by gotmpl. DO NOT MODIFY.
-// source: internal/shared/internaltest/env_test.go.tmpl
-
-// Copyright The OpenTelemetry Authors
-// SPDX-License-Identifier: Apache-2.0
-
-package internaltest
-
-import (
-	"os"
-	"testing"
-
-	"github.com/stretchr/testify/assert"
-	"github.com/stretchr/testify/require"
-	"github.com/stretchr/testify/suite"
-)
-
-type EnvStoreTestSuite struct {
-	suite.Suite
-}
-
-func (s *EnvStoreTestSuite) Test_add() {
-	envStore := newEnvStore()
-
-	e := Env{
-		Name:   "name",
-		Value:  "value",
-		Exists: true,
-	}
-	envStore.add(e)
-	envStore.add(e)
-
-	s.Len(envStore.store, 1)
-}
-
-func (s *EnvStoreTestSuite) TestRecord() {
-	testCases := []struct {
-		name             string
-		env              Env
-		expectedEnvStore *envStore
-	}{
-		{
-			name: "record exists env",
-			env: Env{
-				Name:   "name",
-				Value:  "value",
-				Exists: true,
-			},
-			expectedEnvStore: &envStore{store: map[string]Env{
-				"name": {
-					Name:   "name",
-					Value:  "value",
-					Exists: true,
-				},
-			}},
-		},
-		{
-			name: "record exists env, but its value is empty",
-			env: Env{
-				Name:   "name",
-				Value:  "",
-				Exists: true,
-			},
-			expectedEnvStore: &envStore{store: map[string]Env{
-				"name": {
-					Name:   "name",
-					Value:  "",
-					Exists: true,
-				},
-			}},
-		},
-		{
-			name: "record not exists env",
-			env: Env{
-				Name:   "name",
-				Exists: false,
-			},
-			expectedEnvStore: &envStore{store: map[string]Env{
-				"name": {
-					Name:   "name",
-					Exists: false,
-				},
-			}},
-		},
-	}
-
-	for _, tc := range testCases {
-		s.Run(tc.name, func() {
-			if tc.env.Exists {
-				s.NoError(os.Setenv(tc.env.Name, tc.env.Value))
-			}
-
-			envStore := newEnvStore()
-			envStore.Record(tc.env.Name)
-
-			s.Equal(tc.expectedEnvStore, envStore)
-
-			if tc.env.Exists {
-				s.NoError(os.Unsetenv(tc.env.Name))
-			}
-		})
-	}
-}
-
-func (s *EnvStoreTestSuite) TestRestore() {
-	testCases := []struct {
-		name              string
-		env               Env
-		expectedEnvValue  string
-		expectedEnvExists bool
-	}{
-		{
-			name: "exists env",
-			env: Env{
-				Name:   "name",
-				Value:  "value",
-				Exists: true,
-			},
-			expectedEnvValue:  "value",
-			expectedEnvExists: true,
-		},
-		{
-			name: "no exists env",
-			env: Env{
-				Name:   "name",
-				Exists: false,
-			},
-			expectedEnvExists: false,
-		},
-	}
-
-	for _, tc := range testCases {
-		s.Run(tc.name, func() {
-			envStore := newEnvStore()
-			envStore.add(tc.env)
-
-			// Backup
-			backup := newEnvStore()
-			backup.Record(tc.env.Name)
-
-			s.Require().NoError(os.Unsetenv(tc.env.Name))
-
-			s.NoError(envStore.Restore())
-			v, exists := os.LookupEnv(tc.env.Name)
-			s.Equal(tc.expectedEnvValue, v)
-			s.Equal(tc.expectedEnvExists, exists)
-
-			// Restore
-			s.Require().NoError(backup.Restore())
-		})
-	}
-}
-
-func (s *EnvStoreTestSuite) Test_setEnv() {
-	testCases := []struct {
-		name              string
-		key               string
-		value             string
-		expectedEnvStore  *envStore
-		expectedEnvValue  string
-		expectedEnvExists bool
-	}{
-		{
-			name:  "normal",
-			key:   "name",
-			value: "value",
-			expectedEnvStore: &envStore{store: map[string]Env{
-				"name": {
-					Name:   "name",
-					Value:  "other value",
-					Exists: true,
-				},
-			}},
-			expectedEnvValue:  "value",
-			expectedEnvExists: true,
-		},
-	}
-
-	for _, tc := range testCases {
-		s.Run(tc.name, func() {
-			envStore := newEnvStore()
-
-			// Backup
-			backup := newEnvStore()
-			backup.Record(tc.key)
-
-			s.Require().NoError(os.Setenv(tc.key, "other value"))
-
-			s.NoError(envStore.setEnv(tc.key, tc.value))
-			s.Equal(tc.expectedEnvStore, envStore)
-			v, exists := os.LookupEnv(tc.key)
-			s.Equal(tc.expectedEnvValue, v)
-			s.Equal(tc.expectedEnvExists, exists)
-
-			// Restore
-			s.Require().NoError(backup.Restore())
-		})
-	}
-}
-
-func TestEnvStoreTestSuite(t *testing.T) {
-	suite.Run(t, new(EnvStoreTestSuite))
-}
-
-func TestSetEnvVariables(t *testing.T) {
-	envs := map[string]string{
-		"name1": "value1",
-		"name2": "value2",
-	}
-
-	// Backup
-	backup := newEnvStore()
-	for k := range envs {
-		backup.Record(k)
-	}
-	defer func() {
-		require.NoError(t, backup.Restore())
-	}()
-
-	store, err := SetEnvVariables(envs)
-	assert.NoError(t, err)
-	require.IsType(t, &envStore{}, store)
-	concreteStore := store.(*envStore)
-	assert.Len(t, concreteStore.store, 2)
-	assert.Equal(t, backup, concreteStore)
-}