mirror of https://github.com/tailscale/tailscale/
util/httpm, all: add a test to make sure httpm is used consistently
Updates #cleanup Change-Id: I7dbf8a02de22fc6b317ab5e29cc97792dd75352c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>pull/9639/head
parent
73e53dcd1c
commit
b775a3799e
@ -0,0 +1,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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue