@@ -14,6 +14,8 @@ import (
1414 "runtime"
1515 "testing"
1616
17+ "github.com/cli/cli/v2/internal/gh/ghtelemetry"
18+ "github.com/cli/cli/v2/internal/telemetry"
1719 "github.com/cli/cli/v2/pkg/cmdutil"
1820 "github.com/cli/cli/v2/pkg/httpmock"
1921 "github.com/cli/cli/v2/pkg/iostreams"
@@ -110,7 +112,7 @@ func TestNewCmdCopilot(t *testing.T) {
110112 assert .NoError (t , err )
111113
112114 var gotOpts * CopilotOptions
113- cmd := NewCmdCopilot (f , func (opts * CopilotOptions ) error {
115+ cmd := NewCmdCopilot (f , & telemetry. CommandRecorderSpy {}, func (opts * CopilotOptions ) error {
114116 gotOpts = opts
115117 return nil
116118 })
@@ -586,3 +588,19 @@ func TestDownloadCopilot(t *testing.T) {
586588 require .Equal (t , localPath , path , "downloadCopilot() path mismatch" )
587589 })
588590}
591+
592+ func TestCopilotCommandIsSampledAt100 (t * testing.T ) {
593+ spy := & telemetry.CommandRecorderSpy {}
594+ factory := & cmdutil.Factory {}
595+ cmd := NewCmdCopilot (factory , spy , func (opts * CopilotOptions ) error {
596+ return nil
597+ })
598+ cmd .SetArgs ([]string {})
599+ cmd .SetIn (& bytes.Buffer {})
600+ cmd .SetOut (& bytes.Buffer {})
601+ cmd .SetErr (& bytes.Buffer {})
602+
603+ _ , err := cmd .ExecuteC ()
604+ require .NoError (t , err )
605+ require .Equal (t , ghtelemetry .SAMPLE_ALL , spy .LastSampleRate )
606+ }
0 commit comments