-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When building with Go 1.18+ (we're on 1.22 now), we get version control info in the binary! Since we don't set version numbers, the commit hash (revision) is all we have to identify the version of the code that's running. This adds a `version` chat command that returns a formatted "current build" string. It looks something like this: github.com/recursecenter/pairing-bot (1234567890abcdef1234567890abcdef12345678, built with go1.23.0) And since it might be useful to us for debugging, this also prints the whole buildinfo string at startup.
- Loading branch information
Showing
6 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func Test_dispatch(t *testing.T) { | ||
ctx := context.Background() | ||
projectID := fakeProjectID(t) | ||
|
||
client := testFirestoreClient(t, ctx, projectID) | ||
|
||
pl := &PairingLogic{ | ||
rdb: &FirestoreRecurserDB{client}, | ||
version: "test string", | ||
} | ||
|
||
t.Run("version", func(t *testing.T) { | ||
resp, err := dispatch(ctx, pl, "version", nil, 0, "[email protected]", "Your Name") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
expected := "test string" | ||
if resp != expected { | ||
t.Errorf("expected %q, got %q", expected, resp) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters