summaryrefslogtreecommitdiffhomepage
path: root/util/httpm/httpm_test.go
blob: 77e6309c8807ddfd3ed94d5bb3f64927137bc71a (plain)
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
// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause

package httpm

import (
	"os"
	"os/exec"
	"path/filepath"
	"strings"
	"testing"
)

func TestUsedConsistently(t *testing.T) {
	cmd := exec.Command("git", "grep", "-l", "-F", "http.Method")
	dir, err := os.Getwd()
	if err != nil {
		t.Fatal(err)
	}
	cmd.Dir = filepath.Join(dir, "../..")
	matches, _ := cmd.Output()
	for _, fn := range strings.Split(strings.TrimSpace(string(matches)), "\n") {
		switch fn {
		case "util/httpm/httpm.go", "util/httpm/httpm_test.go":
			continue
		}
		t.Errorf("http.MethodFoo constant used in %s; use httpm.FOO instead", fn)
	}
}