You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: info_test.go
    path of file: ./repos/vald/internal/info
    
    the code of the file until where you have to start completion: //
// Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
//    https://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 info provides build-time info
package info

import (
	"os"
	"reflect"
	"runtime"
	"testing"

	"github.com/vdaas/vald/internal/errors"
	"github.com/vdaas/vald/internal/log"
	"github.com/vdaas/vald/internal/log/logger"
	"github.com/vdaas/vald/internal/strings"
	"github.com/vdaas/vald/internal/sync"
	"github.com/vdaas/vald/internal/test/comparator"
	"github.com/vdaas/vald/internal/test/goleak"
)

// Goroutine leak is detected by `fastime`, but it should be ignored in the test because it is an external package.
var goleakIgnoreOptions = []goleak.Option{
	goleak.IgnoreTopFunction("github.com/kpango/fastime.(*fastime).StartTimerD.func1"),
}

func TestMain(m *testing.M) {
	log.Init(log.WithLoggerType(logger.NOP.String()))
	os.Exit(m.Run())
}

func TestString(t *testing.T) {
	type want struct {
		want *Detail
	}
	type test struct {
		name       string
		want       want
		checkFunc  func(want, string) error
		beforeFunc func(*testing.T)
		afterFunc  func(*testing.T)
	}
	defaultCheckFunc := func(w want, got string) error {
		if got == w.want.String() {
			// check the position of "->"
			var oldIdx int
			for i, str := range strings.Split(strings.TrimPrefix(got, "\n"), "\n") {
				idx := strings.Index(str, "->")
				if i != 0 {
					if oldIdx != idx {
						return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want)
					}
				}
				oldIdx = idx
			}
			return nil
		}
		return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want)
	}
	tests := []test{
		{
			name: "return correct string with no stack trace initialized",
			beforeFunc: func(t *testing.T) {
				t.Helper()
				infoProvider, _ = New(WithServerName(""),
					WithRuntimeCaller(func(skip int) (pc uintptr, file string, line int, ok bool) {
						return uintptr(0), "", 0, false
					}))
			},

    
func TestString(t *testing.T) {
	type want struct {
		want *Detail
	}
	type test struct {
		name       string
		want       want
		checkFunc  func(want, string) error
		beforeFunc func(*testing.T)
		afterFunc  func(*testing.T)
	}
	defaultCheckFunc := func(w want, got string) error {
		if got == w.want.String() {
			// check the position of "->"
			var oldIdx int
			for i, str := range strings.Split(strings.TrimPrefix(got, "\n"), "\n") {
				idx := strings.Index(str, "->")
				if i != 0 {
					if oldIdx != idx {
						return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want)
					}
				}
				oldIdx = idx
			}
			return nil
		}
		return errors.Errorf("\tgot: \"%v\",\n\t\t\t\twant: \"%v\"", got, w.want)
	}
	tests := []test{
		{
			name: "return correct string with no stack trace initialized",
			beforeFunc: func(t *testing.T) {
				t.Helper()
				infoProvider, _ = New(WithServerName(""),
					WithRuntimeCaller(func(skip int) (pc uintptr, file string, line int, ok bool) {
						return uintptr(0), "", 0, false
					}))
			},
			afterFunc: func(t *testing.T) {
				t.Helper()
				once = sync.Once{}
				infoProvider = nil
			},
			want: want{
				want: &Detail{
					Version:           "v0.0.1",
					ServerName:        "",
					GitCommit:         GitCommit,
					BuildTime:         "",
					GoVersion:         runtime.Version(),
					GoOS:              runtime.GOOS,
					GoArch:            runtime.GOARCH,
					GoRoot:            runtime.GOROOT(),
					CGOEnabled:        cgoUnknown,
					AlgorithmInfo:     "",
					BuildCPUInfoFlags: nil,
					StackTrace:        nil,
				},
			},
		},
		{
			name: "return correct string with no information initialized",
			beforeFunc: func(t *testing.T) {
				t.Helper()
				infoProvider = &info{
					rtCaller: func(skip int) (pc uintptr, file string, line int, ok bool) {
						return uintptr(0), "", 0, false
					},
				}
			},
			afterFunc: func(t *testing.T) {
				t.Helper()
				once = sync.Once{}
				infoProvider = nil
			},
			want: want{
				want: &Detail{
					Version:           "",
					ServerName:        "",
					GitCommit:         GitCommit,
					BuildTime:         "",
					GoVersion:         runtime.Version(),
					GoOS:              runtime.GOOS,
					GoArch:            runtime.GOARCH,
					GoRoot:            runtime.GOROOT(),
					CGOEnabled:        cgoUnknown,
					AlgorithmInfo:     "",
					BuildCPUInfoFlags: nil,
					StackTrace:        nil,
				},
			},
		},
	}

	for _, tc := range tests {
		test := tc
		t.Run(test.name, func(tt *testing.T) {
			if test.afterFunc != nil {
				defer test.afterFunc(tt)
			}
			if test.beforeFunc != nil {
				test.beforeFunc(tt)
			}
			checkFunc := test.checkFunc
			if test.checkFunc == nil {
				checkFunc = defaultCheckFunc
			}

			got := String()
			if err := checkFunc(test.want, got); err != nil {
				tt.Errorf("error = %v", err)
			}
		})
	}
}