mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 16:11:57 +00:00
Due to an issue with Autogold and Bazel, we have to migrate all `autogold` tests to use the `v2`. This draft PR loses some annotations describing the test cases, but I'll update that after once I have validate that we can get those to work with Bazel. Why is this a huge PR and not a couple of smaller ones: Because this PR needed a few manual fixes, it was simpler to grind through the changes after running comby locally. I have attached the config below so you can review what I used instead. @chwarwick the code insights tests were heavily relying on the attached description on `autogold.Want` to provide context, I manually ported them by adding a new `name string` field on the test cases. Comby config I used: ``` [update-imports] match="\"github.com/hexops/autogold\"" rewrite="\"github.com/hexops/autogold/v2\"" [update-api-want] match="autogold.Want(:[desc], :[v])" rewrite="autogold.Expect(:[v])" [update-api-equal] match="autogold.Equal(:[v])" rewrite="autogold.ExpectFile(:[v])" ``` ``` $ comby -config ../autogold-comby.toml -matcher .go -exclude-dir vendor,node_modules -in-place ``` I then followed up with some manual fixes for the test cases that were making the assumption that `want.Name()` exists. ## Test plan <!-- All pull requests REQUIRE a test plan: https://docs.sourcegraph.com/dev/background-information/testing_principles --> Green go tests. --------- Co-authored-by: davejrt <davetry@gmail.com>
63 lines
2.3 KiB
Go
63 lines
2.3 KiB
Go
package result
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/hexops/autogold/v2"
|
|
)
|
|
|
|
const input = `client/web/src/enterprise/codeintel/badge/components/IndexerSummary.module.scss client/web/src/enterprise/codeintel/badge/components/IndexerSummary.module.scss
|
|
@@ -1,2 +1,6 @@ ... +1
|
|
+.badge-wrapper {
|
|
+ font-size: 0.75rem;
|
|
+}
|
|
+
|
|
.telemetric-redirect {
|
|
- display: inline !important;
|
|
+ font-size: 0.75rem;
|
|
client/web/src/enterprise/codeintel/badge/components/IndexerSummary.tsx client/web/src/enterprise/codeintel/badge/components/IndexerSummary.tsx
|
|
@@ -57,3 +57,3 @@ export const IndexerSummary: React.FunctionComponent<IndexerSummaryProps> = ({
|
|
return (
|
|
- <div className="px-2 py-1">
|
|
+ <div className={classNames('px-2 py-1', styles.badgeWrapper)}>
|
|
<div className="d-flex align-items-center">
|
|
@@ -61,3 +61,3 @@ export const IndexerSummary: React.FunctionComponent<IndexerSummaryProps> = ({
|
|
{summary.uploads.length + summary.indexes.length > 0 ? (
|
|
- <Badge variant="success" className={className}>
|
|
+ <Badge variant="success" small={true} className={className}>
|
|
Enabled
|
|
@@ -65,3 +65,3 @@ export const IndexerSummary: React.FunctionComponent<IndexerSummaryProps> = ({
|
|
) : summary.indexer?.url ? (
|
|
- <Badge variant="secondary" className={className}>
|
|
+ <Badge variant="secondary" small={true} className={className}>
|
|
Configurable
|
|
client/web/src/enterprise/codeintel/badge/components/RequestLink.module.scss client/web/src/enterprise/codeintel/badge/components/RequestLink.module.scss
|
|
@@ -1,3 +1,5 @@
|
|
.language-request {
|
|
+ font-size: 0.75rem;
|
|
font-weight: normal;
|
|
+ display: inline !important;
|
|
}
|
|
`
|
|
|
|
func TestParseDiffString(t *testing.T) {
|
|
res, err := ParseDiffString(input)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
autogold.ExpectFile(t, res)
|
|
|
|
formatted := FormatDiffFiles(res)
|
|
require.Equal(t, input, formatted)
|
|
|
|
}
|
|
|
|
func TestCommitDiffMatch(t *testing.T) {
|
|
res, _ := ParseDiffString(input)
|
|
commitDiff := &CommitDiffMatch{DiffFile: &res[0]}
|
|
autogold.Expect("client/web/src/enterprise/codeintel/badge/components/IndexerSummary.module.scss").
|
|
Equal(t, commitDiff.Path())
|
|
}
|