File: version_test.go

package info (click to toggle)
golang-golang-x-tools 1%3A0.25.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 22,724 kB
  • sloc: javascript: 2,027; asm: 1,645; sh: 166; yacc: 155; makefile: 49; ansic: 8
file content (31 lines) | stat: -rw-r--r-- 953 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
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gocommand

import (
	"strconv"
	"testing"
)

func TestParseGoVersionOutput(t *testing.T) {
	tests := []struct {
		args string
		want string
	}{
		{"go version go1.12 linux/amd64", "go1.12"},
		{"go version go1.18.1 darwin/amd64", "go1.18.1"},
		{"go version go1.19.rc1 windows/arm64", "go1.19.rc1"},
		{"go version devel d5de62df152baf4de6e9fe81933319b86fd95ae4 linux/386", "devel d5de62df152baf4de6e9fe81933319b86fd95ae4"},
		{"go version devel go1.20-1f068f0dc7 Tue Oct 18 20:58:37 2022 +0000 darwin/amd64", "devel go1.20-1f068f0dc7"},
		{"v1.19.1 foo/bar", ""},
	}
	for i, tt := range tests {
		t.Run(strconv.Itoa(i), func(t *testing.T) {
			if got := ParseGoVersionOutput(tt.args); got != tt.want {
				t.Errorf("parseGoVersionOutput() = %v, want %v", got, tt.want)
			}
		})
	}
}