hunk.code_window: 	analytics "github.com/segmentio/analytics-go"
   )
   const (
   	SEGMENT_KEY = "fwb7VPbFeQ7SKp3wHm1RzFUuXZudqVok"
   	TRACK_CONFIG_SERVICE            = "config_service"
   	TRACK_CONFIG_TEAM               = "config_team"
   	TRACK_CONFIG_CLIENT_REQ         = "config_client_requirements"
  
hunk.labels: keep keep keep keep replace keep keep keep keep
hunk.after_edit: 	SEGMENT_KEY = "placeholder_segment_key"
  
hunk.file_path: app/diagnostics.go
hunk.type: replace
file: package plugintest_test
  
  import (
  	"fmt"
  	"io/ioutil"
  	"net/http"
  	"net/http/httptest"
  	"testing"
  
  	"github.com/stretchr/testify/assert"
  	"github.com/stretchr/testify/require"
  
  	"github.com/mattermost/mattermost-server/model"
  	"github.com/mattermost/mattermost-server/plugin"
  	"github.com/mattermost/mattermost-server/plugin/plugintest"
  )
  
  type HelloUserPlugin struct {
  	plugin.MattermostPlugin
  }
  
  func (p *HelloUserPlugin) ServeHTTP(context *plugin.Context, w http.ResponseWriter, r *http.Request) {
  	userId := r.Header.Get("Mattermost-User-Id")
  	user, err := p.API.GetUser(userId)
  	if err != nil {
  		w.WriteHeader(http.StatusBadRequest)
  		p.API.LogError(err.Error())
  		return
  	}
  
  	fmt.Fprintf(w, "Welcome back, %s!", user.Username)
  }
  
  func Example() {
  	t := &testing.T{}
  	user := &model.User{
  		Id:       model.NewId(),
  		Username: "billybob",
  	}
  
  	api := &plugintest.API{}
  	api.On("GetUser", user.Id).Return(user, nil)
  	defer api.AssertExpectations(t)
  
  	p := &HelloUserPlugin{}
  	p.SetAPI(api)
  
  	w := httptest.NewRecorder()
  	r := httptest.NewRequest("GET", "/", nil)
  	r.Header.Add("Mattermost-User-Id", user.Id)
  	p.ServeHTTP(&plugin.Context{}, w, r)
  	body, err := ioutil.ReadAll(w.Result().Body)
  	require.NoError(t, err)
  	assert.Equal(t, "Welcome back, billybob!", string(body))
  }
  